here is one way:-- making testdatadeclare @test table (id int, valueid int, [values] int)insert @testselect 5, 59, 125 union allselect 5, 60, 30 union allselect 5, 61, 10 union allselect 6, 59, 125 union allselect 6, 60, 20 union allselect 6, 61, 10-- show testdataselect * from @test-- solutionselect distinct id from @test t1where exists (select * from @test t2 where t1.id=t2.id and t2.[values] = 125 )and exists (select * from @test t2 where t1.id=t2.id and t2.[values] = 30 )and exists (select * from @test t2 where t1.id=t2.id and t2.[values] = 10 )
No, you're never too old to Yak'n'Roll if you're too young to die.