In SQL, 1. Write a SELECT statement that returns these columns from the Invoices
ID: 3822938 • 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 FORMAT function to return the invoice_total column with 1 digit to the right of the decimal point
- A column that uses the CONVERT function to return the invoice_total column as an integer
- A column that uses the CAST function to return the invoice_total as an integer.
2. Write a SELECT statment that returns these columns from the Invoices table:
- The invoice_date column
- A column that uses the CAST function to return the invoice_date column with its full date and time
- A column that uses the CAST function to return the invoice_date column with just the year and the month
Explanation / Answer
1. Select
invoice_total,
FORMAT(invoice_total,'n', 'de') As invoice_total_FORMAT,
convert(int,invoice_total) as invoice_total_convert,
cast(invoice_total as int) invoice_total_CAST
from Invoices
2. Select
invoice_date ,
cast(invoice_date as datetime),
CAST(DateAdded AS varchar(6))
from Invoices
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.