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-1.sql 369B

12345678910111213141516
  1. CREATE TABLE invoices_copy AS
  2. SELECT *
  3. FROM invoices;
  4. CREATE TABLE old_invoices AS
  5. SELECT *
  6. FROM invoices
  7. WHERE invoice_total - payment_total - credit_total = 0;
  8. CREATE TABLE vendor_balances AS
  9. SELECT vendor_id, SUM(invoice_total) AS sum_of_invoices
  10. FROM invoices
  11. WHERE (invoice_total - payment_total - credit_total) <> 0
  12. GROUP BY vendor_id;
  13. DROP TABLE old_invoices;