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.

demo-queries-from slides-04.sql 407B

1234567891011
  1. SELECT invoice_number, invoice_date,
  2. invoice_total - payment_total - credit_total AS balance_due
  3. FROM invoices
  4. WHERE invoice_total - payment_total - credit_total > 0
  5. AND invoice_total - payment_total - credit_total <
  6. (
  7. SELECT AVG(invoice_total - payment_total - credit_total)
  8. FROM invoices
  9. WHERE invoice_total - payment_total - credit_total > 0
  10. )
  11. ORDER BY invoice_total DESC;