Question: 9.3) MySQL Question Write a SELECT statement that returns these columns from the Orders table: The card_number column The length of the card_number column aliased

9.3) MySQL Question

Write a SELECT statement that returns these columns from the Orders table:

  • The card_number column
  • The length of the card_number column aliased as card_number_length
  • The last four digits of the card_number column aliased as last_four_digits
  • 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-XXXX-1234, 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. (Hint: Use an IF function to determine which format to use.). This column should be aliased as formatted_number

Sort the result set by the card_number column in ascending sequence.

The script to generate the my_guitar_shop database is here:

https://pastebin.com/QwF3ZYsR

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!