Question
Chapter 8 How to work with data types and functions Exercises 1. Write a SELECT statement that returns these columns from the Invoices table: The
Chapter 8
How to work with data types and functions
Exercises
1. Write a SELECT statement that returns these columns from the Invoices table:
The invoice_total column
Use the TO_CHAR function to return the invoice_total column with 2 digits to the right of the decimal point.
Use the TO_CHAR function to return the invoice_total column with no digits to the right of the decimal point and no decimal point
Use the CAST function to return the invoice_total column as an integer with seven digits
2. Write a SELECT statement that returns these columns from the Invoices table:
The invoice_date column
Use the TO_CHAR function to return the invoice_date column with its full date and time including a four-digit year on a 24-hour clock
Use the TO_CHAR function to return the invoice_date column with its full date and time including a four-digit year on a 12-hour clock with an am/pm indicator
Use the CAST function to return the invoice_date column as VARCHAR2(10)
3. Write a SELECT statement that returns these columns from the Vendors table:
The vendor_name column
The vendor_name column in all capital letters
The vendor_phone column
The last four digits of each phone number
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.
The second word in each vendor name if there is one; otherwise, blanks
The vendor_phone column with the parts of the number separated by dots as in 555.555.5555
4. Write a SELECT statement that returns these columns from the Invoices table:
The invoice_number column
The invoice_date column
The invoice_date column plus 30 days
The payment_date column
A column named days_to_pay that shows the number of days between the invoice date and the payment date
The number of the invoice_dates month
The four-digit year of the invoice_date
The last day of the invoice dates month
When youve got this working, add a WHERE clause that retrieves just the invoices for the month of May based on the invoice date, not the number of the invoice month.
5. Write a SELECT statement that returns these columns from the Invoices table:
The invoice_number column
The balance due (invoice total minus payment total minus credit total) with commas, a decimal point, and two decimal positions
A column named Balance Rank that uses the RANK function to return a column that ranks the balance due in descending order.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started