In SQL, 1. Write a SELECT statement that returns these columns from the invoices
ID: 3822948 • Letter: I
Question
In SQL,
1. Write a SELECT statement that returns these columns from the invoices table :
- The invoice_total column
- A column that uses the ROUND function to return the invoice total column with a 1 decimal digit
- A column that uses the ROUND function to return the invoice total column with NO decimal digits
2. Write a select statement that returns these columns from the date_sample table to the EX database:
- The start_date column
- A column that uses the DATE_FORMAT function to return the Start_Date column with its month name abbreviated and its month, day, and two-digit year seperated by slashes
- A column that uses the DATE_FORMAT function to retrun the Start_Date column with its month and day returned as integers with no leading zeros, a two-digit year, and all date parts seperated by slashes.
- A column that uses the DATE_FORMAT function to return the Start_Date column with only the hours and minutes on a 12-hour with an AM/PM indicator
- A column that uses the DATE_FORMAT function to return the Start_Date column with its month returned as an integer with no leading zeros, its month, day, and two-digit year seperated by slashes, and its hours and minutes on a 12-hour clock with an AM/PM indicator.
Explanation / Answer
1. Select invoice_total,
ROUND(invoice_total,1),
ROUND(invoice_total,0)
from invoices
Round function rounded to the specified length or precision.
2.
Select
start_date,
CONVERT(VARCHAR(8), start_date, 1),
CAST(MONTH(start_date) AS VARCHAR(2)) + '/' + CAST(DAY(start_date) AS VARCHAR(2)) + '/' + RIGHT(CAST(YEAR(start_date) AS VARCHAR(4)), 2),
FORMAT(start_date, 'hh:mm tt'),
CONVERT(VARCHAR(20), start_date, 22)
from date_sample
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.