I have a table that looks like this:
I wanted to create a query that gives me a group by OrderID and Canbefulfilled but if there is a single 0 in Canbefulfilled column , I want that column to be 0
I the above case I am expecting, since OrderID 30
has one 0
OrderID CanbeFulfilled 27 0 28 0 30 0
Query wise
Select OrderID, Return0IfThereIfAny0(CanBeFulFilled) FROM Table1 GROUP BY OrderID
I cannot figure out how I can do the Return0IfThereIsAny0
part.
Advertisement
Answer
I think min()
does what you want:
SELECT OrderID, MIN(CanBeFulFilled) FROM Table1 GROUP BY OrderID