Skip to content

Commit

Permalink
insight_1_products_sold 0236_13062023
Browse files Browse the repository at this point in the history
  • Loading branch information
bharathguntreddi3 committed Jun 13, 2023
1 parent 24b564f commit 09328cb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Products_Sold.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Most often sold products
SELECT DISTINCT ORDERNUMBER, STUFF(
(SELECT ',' + PRODUCTCODE
FROM sales_data AS p
WHERE ORDERNUMBER IN
(
SELECT ORDERNUMBER
FROM
(
SELECT ORDERNUMBER, COUNT(*) AS quantity
FROM sales_data
WHERE STATUS = 'shipped'
GROUP BY ORDERNUMBER
) AS b
WHERE quantity = 9
)
AND p.ORDERNUMBER = s.ORDERNUMBER
FOR XML PATH('')), 1, 1, '') AS ProductCodes
FROM sales_data AS s
ORDER BY ProductCodes DESC

0 comments on commit 09328cb

Please sign in to comment.