Sql查询来安排每个团队之间的匹配

Sql查询来安排每个团队之间的匹配

本文介绍了Sql查询来安排每个团队之间的匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have a table with these columns like,
country
-------
India
Pak
Aus
I need to generate the output like,
Output:
-------
India vs Aus
India vs Pak
Pak vs Aus





我尝试过:



我尝试使用Sqlsever加入使用row_numbers(),但我无法解决。任何人都可以帮我解决这个问题。



What I have tried:

I have tried with Sqlsever joins with using row_numbers() but i unable to solve . Can anyone help me out this.

推荐答案

DECLARE @table TABLE (
   ndx INT IDENTITY(1,1) NOT NULL,
   Team VARCHAR(16)
)
INSERT @table
VALUES ('One')
,      ('Two')
,      ('Three')

SELECT  t1.Team, t2.Team
FROM       @table  t1
INNER JOIN @table  t2 ON t1.ndx < t2.ndx



这将给你回报


Will return you this

Home  Guest
----  -----
One   Two
One   Three
Two   Three



这篇关于Sql查询来安排每个团队之间的匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 10:14