goxarad784
goxarad784

Reputation: 435

Get all group by values in column a where all values in another column is true

I have a table that looks like this:

enter image description here

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.

Upvotes: 0

Views: 37

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1270463

I think min() does what you want:

SELECT OrderID, MIN(CanBeFulFilled)
FROM Table1
GROUP BY OrderID

Upvotes: 2

Related Questions