way one
SELECT y.*
FRM YourTable y join(
SELECT orderid
FRM YourTable
GRUP BY orderid
HAVING ****(orderdetailid) 1) x on y.orderid = x.orderid
or this way, a little faster
SELECT y.*
FRM YourTable y
where exists (select orderid from YourTable where orderid = y.orderid
GRUP BY orderid
HAVING ****(orderdetailid) 1)
here is the complete script to play around with
CREATE Table YourTable (orderid int, orderdetailid int)
INSERT INT YourTable values(0,1)
INSERT INT YourTable values(1,1)
INSERT INT YourTable values(2,1)
INSERT INT YourTable values(3,1)
INSERT INT YourTable values(4,1)
INSERT INT YourTable values(1234,1)
INSERT INT YourTable values(1234,2)
INSERT INT YourTable values(1234,3)
INSERT INT YourTable values(5421,1)
INSERT INT YourTable values(5421,2)
SELECT y.*
FRM YourTable y join(
SELECT orderid
FRM YourTable
GRUP BY orderid
HAVING ****(orderdetailid) 1) x on y.orderid = x.orderid
SELECT y.*
FRM YourTable y
where exists (select orderid from YourTable where orderid = y.orderid
GRUP BY orderid
HAVING ****(orderdetailid) 1)
Denis the SQL Menace