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 Products table: The

ID: 3694512 • Letter: W

Question

Write a SELECT statement that returns these columns from the Products table: The list_price column The discount_percent column A column named discount_amount that uses the previous two columns to calculate the discount amount and uses the ROUND function to round the result so it has 2 decimal digits Write a SELECT statement that returns these columns from the Orders table: The order_date column A column that uses the DATE_FORMAT function to return the four-digit year that's stored in the order_date column A column that uses that DATE_FORMAT function to return the order_date column in this format: Mon-DD-YYYY. In other words, use abbreviated months and separate each date component with dashes. A column that uses the DATE_FORMAT function to return the order_date column with only the hours and minutes on a 12-hour clock with an am/pm indicator A column that uses the DATE_FORMAT function to return the order_date column in this format: MM/DD/YY HH:SS. In other words, use two-digit months, days, and years and separate them by slashes. Use 2-digit hours and minutes on a 24-hour clock. And use lending zeros for all date/time components. Write a SELECT statement that return these columns from the Orders table: The card_numbercolumn 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

SELECT list_price, discount_percent FROM `products`

SELECT date_format(order_date, '%Y') FROM `orders`

SELECT card_number, length(card_number), SUBSTRING(card_number, -4) FROM orders

To replace number with ‘X’ I tryied following query , but unable to keep dash

SELECT CONCAT( REPEAT('X', CHAR_LENGTH(card_number) - 4), SUBSTRING(card_number, -4) ) AS x_card 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