I have a homework problem where it asks me to
Write a select statement based on the InvoiceTotal column of the Invoices table
It wants me to take that column and run 3 different CAST functions on it andchange the data type. I know how to do that, but how do I select the column based on the table its in? Or is it basically saying to just select that table and include it in the result set along with the other columns I create using the cast function? But I think they don’t want the original InvoiceTotal Column included in the result set?
Task: Write a select statement based on the InvoiceTotal column of the Invoices table:
Use the CAST function to return the first column as an integer
value. Name it IntTotal.
Use the CAST function to return the second column as datatype decimal with one
digit to the right. Name it DecimalTotal.
Use the CONVERT function to return the third column as a datatype
that outputs 2 digits to the right of the decimal point and all comma’s to the
left (i.e. 3, 106.34). Name it FormatTotal.
*/
USE AP
SELECT InvoiceTotal,
CAST(InvoiceTotal AS int) intTotal,
CAST(InvoiceTotal AS decimal(8,1)) DecimalTotal
FROM Invoices;