1234567891011121314151617181920 |
- --A SELECT statement that calculates the balance due
- SELECT invoice_total, payment_total, credit_total,
- invoice_total - payment_total - credit_total AS balance_due
- FROM invoices;
-
-
- --Use parentheses to control the sequence of operations
- SELECT invoice_id,
- invoice_id + 7 * 3 AS multiply_first,
- (invoice_id + 7) * 3 AS add_first
- FROM invoices
- ORDER BY invoice_id;
-
- --Use the DIV and modulo operators
- SELECT invoice_id,
- invoice_id / 3 AS decimal_quotient,
- invoice_id DIV 3 AS integer_quotient,
- invoice_id % 3 AS remainder
- FROM invoices
- ORDER BY invoice_id;
|