如果你想超过1排在第二cloumn然后
create table #temp(ID int, num1 int, num2 int)
insert into #temp values (1,123,234)
insert into #temp values (2,234,345)
insert into #temp values (3,345,123)
insert into #temp values (4,567,123)
--query just to create a dummy table fro your reference
--main query starts from here
select * from #temp where ID in
(select t1.id from #temp t1, #temp t2
where t1.num1 = t2.num2 and t1.num1 = 123) or ID in
(select t2.id from #temp t1, #temp t2
where t1.num1 = t2.num2 and t1.num1 = 123)
--sorry for not indenting it
drop table #temp
--returns
--ID num1 num2
-- 1 123 234
-- 3 345 123
-- 4 567 123
按两列分组... EmpidNum Group,EmpAddNum – Mate 2013-02-17 09:50:39
我不明白你的意思。第一种情况下你在说什么ID?根据示例数据,你想要什么结果? – Guffa 2013-02-17 09:54:50
向我们展示您的理想结果 – 2013-02-17 11:11:42