Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT * FROM
- (
- 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
- FROM Customer
- INNER JOIN Commercial
- ON Commercial.Customer_ID = Customer.Customer_ID
- INNER JOIN Order_Table
- ON Order_Table.Customer_ID = Customer.Customer_ID
- INNER JOIN Order_Item
- ON Order_Item.Order_ID = Order_Table.Order_ID
- INNER JOIN Product
- ON Order_Item.Product_ID = Product.Product_ID
- INNER JOIN Product_Catagory_Link
- ON Product.Product_ID = Product_Catagory_Link.Product_ID
- INNER JOIN Product_Catagory
- ON Product_Catagory_Link.Product_Catagory_ID = Product_Catagory.Product_Catagory_ID
- GROUP BY Customer.First_Name, Customer.Last_Name, Customer.Customer_ID, Commercial.Company_Name, Product_Catagory.Product_Catagory_Description
- ORDER BY Product_Catagory_Count DESC
- )
- WHERE Customer_ID = 5 AND ROWNUM = 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement