You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exer_5C20.sql 812B

123456789101112131415161718192021
  1. USE AP;
  2. SELECT invoice_number, vendor_name, '33% PAYMENT' AS payment_type,
  3. invoice_total AS total, invoice_total * 0.333 AS payment
  4. FROM invoices JOIN vendors
  5. ON invoices.vendor_id = vendors.vendor_id
  6. WHERE invoice_total > 10000
  7. UNION
  8. SELECT invoice_number, vendor_name, '50% PAYMENT' AS payment_type,
  9. invoice_total AS total, invoice_total * 0.500 AS payment
  10. FROM invoices JOIN vendors
  11. ON invoices.vendor_id = vendors.vendor_id
  12. WHERE invoice_total BETWEEN 500 AND 10000
  13. UNION
  14. SELECT invoice_number, vendor_name, 'FULL PAYMENT' AS payment_type,
  15. invoice_total AS total, invoice_total AS payment
  16. FROM invoices JOIN vendors
  17. ON invoices.vendor_id = vendors.vendor_id
  18. WHERE invoice_total < 500
  19. ORDER BY payment_type, vendor_name, invoice_number;
  20. /* 3 unions van 4 tabellen