Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
c) Using SET operators, date – time functions, roll up, cube and grouping sets
1. Use UNION operator to generate a result set consisting of two columns from the
vendors table: vendor_name & vendor_state. If the vendor is in California the
vendor_state value should be “CA”; otherwise the vendor_state value should be
“outside CA”. Sort the final result set by vendor_ name.
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 – hr 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-hr clock with an am/pm indicator.
3. 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
invoice_date and the payment_date
• The number of the invoice_date’s month
• The four digit year of the invoice_date
• The last day of the invoice date’s month.
When you have 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 invoice month.
4. What is total amount invoiced for each general ledger account number? Use ROLLOUP
operator to include a row that gives the grand total. Hint: use the line_item_amt
column of the Invoice_Line_Items table. (also observe the difference when we use CUBE
operator)