question

Rashid avatar image
Rashid asked

Want to produce report group by distributor

SELECT DISTRIBUTOR , NEW_PROD , DISCONTINUE FROM ( SELECT DISTRIBUTOR = ( SELECT distributor FROM InventoryReportDB.dbo.DAILY_INVENTORY_DATA GROUP BY distributor ) , NEW_PROD = ( SELECT COUNT(*) NEW_PROD FROM InventoryReportDB.dbo.DAILY_INVENTORY_DATA INV WHERE NOT EXISTS ( SELECT 'x' FROM Amazon.dbo.FlatTableProducts az WHERE LTRIM(RTRIM(az.DistributorSKU)) = INV.ITEM_Number AND Distributor = LTRIM(RTRIM(INV.Distributor)) ) GROUP BY distributor ) , DISCONTINUE = ( SELECT COUNT(*) DISCONTINUE FROM Amazon.dbo.FlatTableProducts az WHERE Distributor IN ( 'Alpha Shirt', 'Bodek & Rhodes', 'Sanmar', 'Tri-Mountain' ) AND NOT EXISTS ( SELECT 'x' FROM InventoryReportDB.dbo.DAILY_INVENTORY_DATA INV WHERE az.DistributorSKU = LTRIM(RTRIM(INV.ITEM_Number)) AND Distributor = LTRIM(RTRIM(INV.Distributor)) ) GROUP BY Distributor ) ) SUMMARY
selectivity
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Is there a particular question you have in regards to this?
2 Likes 2 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.