我有一张表格如下:
Country_ID | Country_name
-----------+-------------
1 | India
2 | Srilanka
3 | South Africa
4 | Australia
我现在需要一个查询来显示如下数据:
Match ID | Match Details
---------+---------------------------
1 | India V/s Srilanka
2 | India V/s South Africa
3 | India V/s Australia
4 | Srilanka V/s South Africa
5 | Srilanka V/s Australia
6 | South Africa V/s Australia
答案 0 :(得分:2)
我想你想要自己加入更高ID的表
select
row_number() over (order by a.country_id, b.country_id)
, a.country_name + ' v/s ' + b.country_name
from
myTable a
join myTable b on a.country_id < b.country_id