Skip to content

Instantly share code, notes, and snippets.

@Cvetomird91
Last active February 22, 2020 10:14
Show Gist options
  • Save Cvetomird91/609c0c9d1b0f6e066d5b4c1a653b1f77 to your computer and use it in GitHub Desktop.
Save Cvetomird91/609c0c9d1b0f6e066d5b4c1a653b1f77 to your computer and use it in GitHub Desktop.
SELECT * FROM CUSTOMERS, ORDERS, ORDER_ITEMS
WHERE CUSTOMERS.CUSTOMER_ID = ORDERS.CUSTOMER_ID and ORDERS.ORDER_ID = ORDER_ITEMS.ORDER_ID;
SELECT CUSTOMERS.FNAME, CUSTOMERS.LNAME, count(distinct ORDERS.ORDER_ID) Orders, sum(ORDER_ITEMS.UNIT_PRICE * ORDER_ITEMS.QUANTITY) FROM CUSTOMERS, ORDERS, ORDER_ITEMS
WHERE CUSTOMERS.CUSTOMER_ID = ORDERS.CUSTOMER_ID and ORDERS.ORDER_ID = ORDER_ITEMS.ORDER_ID group by CUSTOMERS.FNAME, CUSTOMERS.LNAME order by 4 desc;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment