Advertisement
yatahaze

PavloSheichenko

Mar 20th, 2023
834
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.31 KB | None | 0 0
  1. SELECT c.CategoryName, c.CategoryID, SUM(od.Quantity) as TotalQuantity
  2. FROM Categories c
  3. JOIN Products p ON c.CategoryID = p.CategoryID
  4. JOIN OrderDetails od ON p.ProductID = od.ProductID
  5. JOIN Orders o ON od.OrderID = o.OrderID
  6. WHERE o.OrderDate LIKE "1997%"
  7. GROUP BY c.CategoryID
  8. ORDER BY TotalQuantity DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement