123456789101112131415161718192021 |
- USE AP;
- SELECT invoice_number, vendor_name, '33% PAYMENT' AS payment_type,
- invoice_total AS total, invoice_total * 0.333 AS payment
- FROM invoices JOIN vendors
- ON invoices.vendor_id = vendors.vendor_id
- WHERE invoice_total > 10000
- UNION
- SELECT invoice_number, vendor_name, '50% PAYMENT' AS payment_type,
- invoice_total AS total, invoice_total * 0.500 AS payment
- FROM invoices JOIN vendors
- ON invoices.vendor_id = vendors.vendor_id
- WHERE invoice_total BETWEEN 500 AND 10000
- UNION
- SELECT invoice_number, vendor_name, 'FULL PAYMENT' AS payment_type,
- invoice_total AS total, invoice_total AS payment
- FROM invoices JOIN vendors
- ON invoices.vendor_id = vendors.vendor_id
- WHERE invoice_total < 500
- ORDER BY payment_type, vendor_name, invoice_number;
-
- /* 3 unions van 4 tabellen
|