asked on
ASKER
select orderid
FROM orderheader
where isfulfilled = 0 and inprocess=0
and OrderId in (
SELECT oh.orderid FROM
OrderHeader oh
inner join OrderLines ol on oh.OrderId = ol.OrderId
WHERE oh.OrderId in (SELECT OrderId from OrderLines group by OrderId having COUNT(*) > 0)
and ol.ProductId > 225)
and OrderId not in (
SELECT oh.orderid FROM
OrderHeader oh
inner join OrderLines ol on oh.OrderId = ol.OrderId
WHERE oh.OrderId in (SELECT OrderId from OrderLines group by OrderId having COUNT(*) > 0)
and ol.ProductId < 226)
select orderid from (
select orderid, sum(case when ProductID>255 then 1 else 0 end) cntGT255, count(1) cnt
from orderLines o
group by orderid
) x where cnt=cntGT255
ASKER
ASKER
Microsoft SQL Server 2005 is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning. It includes support for managing XML data and allows a database server to be exposed over web services using Tabular Data Stream (TDS) packets encapsulated within SOAP (protocol) requests.
TRUSTED BY
select orderid
FROM orderheader oh
inner join OrderLines ol on oh.OrderId = ol.OrderId and ol.ProductId > 225