I have a stock table which holds for example
Partnumber | Depot | flag_redundant ------------+-------+---------------- 1 | 1 | 5 1 | 2 | 0 1 | 3 | 0 1 | 4 | 5 2 | 1 | 0 2 | 2 | 0 2 | 3 | 0 2 | 4 | 0 I need to be able to see the depots in which the parts have not been flagged as redundant, but the flag_redundant has been at least been flagged once for that part, and I need to ignore any parts where there has not been a flag flagged.
Any help appreciated!
I'm thinking of something along the lines of ....
SELECT stock.part, stock.depot, OrderCount = (SELECT CASE WHEN Stock.flag_redundant = 5 THEN 1 end as Countcolumn FROM stock C) FROM stock Partnumber | MissingDepots ------------+--------------- 1 | Yes