Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Peter2138
Starting Member
2 Posts |
Posted - 2012-08-14 : 04:10:02
|
| Hi All,I have orders with orderlines, those orderlines have a status and a warehouse. The warehouse SEC is our mainwarehouse, and orderline status 30 is "completed"How do I select complete orders? So, orders where all orderstatus with warehouse SEC are 30? (there may be other warehouses in an order but that's not an issue) |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-08-14 : 04:27:08
|
SELECT OrderNumber FROM dbo.OrderLines GROUP BY OrderNumber HAVING MIN(CASE WHEN Warehouse = '30' THEN 1 ELSE 0 END) = 1 N 56°04'39.26"E 12°55'05.63" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2012-08-14 : 04:27:49
|
SELECT OrderNumber FROM dbo.OrderLines GROUP BY OrderNumber HAVING MIN(CASE WHEN Status = '30' THEN 1 ELSE 0 END) = 1 N 56°04'39.26"E 12°55'05.63" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-08-14 : 10:34:07
|
it should beSELECT OrderNumber FROM dbo.OrderLines GROUP BY OrderNumber HAVING MAX(CASE WHEN Warehouse='SEC' AND Status !='30' THEN 1 ELSE 0 END) =0 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|