62.9k views
5 votes
Write a SELECT statement that returns these columns from the Orders table: The card_number column The length 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. The last four digits of the card_number column A column that displays an X for each digit of the card_number column except for the last four digits. If the card number contains 16 digits, it should be displayed in this format: XXXX-XXXX-XXXX1234, where 1234 are the actual last four digits of the number. If the card number contains 15 digits, it should be displayed in this format: XXXX-XXXXXX-X1234

1 Answer

3 votes

Answer:

Select CardNumber, LEN(cardNumber) as CARDLEN,

Right (CardNumberR,4) AS LAST4DIGITS FROM ORDER

Step-by-step explanation:

User Verna
by
3.5k points