Skip to content
Advertisement

Slow Moving Stock Items Query

I am trying to return a list of slow-moving stock items. Whenever there is a sale, the items are written to the saleItems table. I want to get those items from inventoryMaster table that are not appearing in the saleItems table within the past N days. Here is my structure.

below is the query which gives me an error

Advertisement

Answer

Use NOT EXISTS with a correlated subquery.

The subquery ensures that, for the given item in the inventory, no record exists in the sales table over the last 90 days.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement