Write a SELECT statement that returns these columns from the Orders table: The c
ID: 3829798 • Letter: W
Question
Write a SELECT statement that returns these columns from the Orders table:
The card_number column
The length of the card_number column
The last four digits of the card_number column
When you get that working right, add the columns that follow to the result set. This is more difficult because these columns require the use of functions within functions.
A column that displays the last four digits of the card_number column in this format: XXXX-XXXX-XXXX-1234. In other words, use Xs for the first 12 digits of the card number and actual numbers for the last four digits of the number.
Explanation / Answer
SQL query is as below:
length(str)-> is used to return the length
substring(str,start,len)--> used to return the last four digits
Query:
Select card_number, length(card_number) as card_length,substring(card_number,16,4) as four_digits
from Orders
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.