MySQL query to find Products that were sold on both the days [closed]
I have to write a MySQL query: Find products that were sold on both the days (01-JUL-11 and 02-JUL-11) and number of total product sold. The table looks like: Date, Order_id, Product_id, Quantity '01-JUL-11',O1,P1,5 '01-JUL-11',O2,P2,2 '01-JUL-11',O3,P3,10 '01-JUL-11',O4,P1,10 '02-JUL-11',O5,P3,5 '02-JUL-11',O6,P4,6 '02-JUL-11',O7,P1,2 '02-JUL-11',O8,P5,1 '02-JUL-11',O9,P6,2 '02-JUL-11',O10,P2,4 Output: P1 17 P2 6 P3 15 So far I have tried is: SELECT PRODUCT_ID, TOTAL FROM (SELECT PRODUCT_ID, COUNT(PRODUCT_ID) AS COUNTER, SUM(TOTAL) TOTAL FROM (Select ORDER_DAY, PRODUCT_ID, SUM(QUANTITY) AS TO
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.