Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote