0% found this document useful (0 votes)
12 views1 page

SQL Queries for Customer and Order Data

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views1 page

SQL Queries for Customer and Order Data

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

SELECT * FROM Customers;

SELECT * FROM Orders;


SELECT * FROM OrderDetails;
SELECT * FROM Products;
SELECT Orders.c1, Orders.c3, Orders.c4, Orders.c5, Customers.c4 FROM Orders JOIN
Customers ON Orders.c2 = Customers.c1;
SELECT * FROM Orders JOIN Customers ON Orders.c2 = Customers.c1;
SELECT Products.c2, SUM(OrderDetails.c4) AS tquan FROM OrderDetails JOIN Products
on OrderDetails.c3 = Products.c1
GROUP by Products.c2 ORDER BY tquan DESC;
SELECT c2 FROM Customers WHERE Customers.c1 IN(SELECT c2 FROM Orders WHERE
Orders.c4 >= date('2024-08-30','-18 months'));

You might also like