Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. SELECT * FROM
  2. (
  3. SELECT Customer.Customer_ID,Customer.First_Name,Customer.Last_Name,Commercial.Company_Name,Product_Catagory.Product_Catagory_Description, COUNT(Product_Catagory.Product_Catagory_ID) AS Product_Catagory_Count
  4. FROM Customer
  5. INNER JOIN Commercial
  6. ON Commercial.Customer_ID = Customer.Customer_ID
  7. INNER JOIN Order_Table
  8. ON Order_Table.Customer_ID = Customer.Customer_ID
  9. INNER JOIN Order_Item
  10. ON Order_Item.Order_ID = Order_Table.Order_ID
  11. INNER JOIN Product
  12. ON Order_Item.Product_ID = Product.Product_ID
  13. INNER JOIN Product_Catagory_Link
  14. ON Product.Product_ID = Product_Catagory_Link.Product_ID
  15. INNER JOIN Product_Catagory
  16. ON Product_Catagory_Link.Product_Catagory_ID = Product_Catagory.Product_Catagory_ID
  17. GROUP BY Customer.First_Name, Customer.Last_Name, Customer.Customer_ID, Commercial.Company_Name, Product_Catagory.Product_Catagory_Description
  18. ORDER BY Product_Catagory_Count DESC
  19. )
  20. WHERE Customer_ID = 5 AND ROWNUM = 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement