小组:
s: Any, "lazy-if", \(1)
输出:
1 India
2 Pakistan
3 Srilanka
4 Australia
答案 0 :(得分:0)
我相信你在寻找这个。假设您的原始表名为'#temp2'
select a.string+' VS '+b.string from #temp2 a cross join #temp2 b
where a.string = 'Australia' and a.string<>b.string
union all
select a.string+' VS '+b.string from #temp2 a cross join #temp2 b
where a.string = 'Srilanka' and a.string<>b.string and b.string not in (Select a.string from #temp2 a cross join #temp2 b
where a.string = 'Australia')
union all
select a.string+' VS '+b.string from #temp2 a cross join #temp2 b
where a.string = 'Pakistan' and a.string<>b.string
and b.string not in (Select a.string from #temp2 a cross join #temp2 b
where a.string = 'Australia')
and b.string not in (Select a.string from #temp2 a cross join #temp2 b
where a.string = 'Srilanka')
答案 1 :(得分:0)
这有效:
SELECT ROW_NUMBER() OVER(Order By (Select null)),t2.Name +' VS '+ t1.Name
FROM Team t1
JOIN Team t2 on t2.id>t1.Id
order by t2.Id,t1.Id desc