Product Name Product Id Product Status
A 1 Rollout
A 1 Storage
A 1 Delivered
A 5 Storage
B 2 Rollout
C 3 Rollout
A 4 Rollout
A 5 Rollout
B 6 Rollout
C 7 Rollout
In the above table I want to write below query which should return the result like
Product Name QOH
A 1
B 0
C 0
Query:
SELECT Product Name, Count(Product Id)
FROM table_t1
WHERE Product Status IN ('Storage') AND Product Status NOT IN ('Delivered')
But the above query returns following result
Product Name QOH
A 2
B 0
C 0
Please help.
QOHis computed from the count of[product id]?[Product Status] IN ('Storage') AND [Product Status] NOT IN ('Delivered')is an illogical condition. If the Status isStoragethen it won't beDelivered, is not rocket science.