Comparing the same row in SQL Server table -


how display result india vs pakistan, india vs sri lanka, india vs bangladesh, bangladesh vs sri lanka, bangladesh vs pakistan, pakistan vs sri lanka below table?

teams ------- india pakistan sri lanka bangladesh 

for example:

--output: bangladesh vs. india bangladesh vs. sri lanka bangladesh vs. pakistan india vs. sri lanka india vs. pakistan pakistan vs. sri lanka 

i guess looking non repeating combinations of team matches. try below:

create table temp (     team varchar(100) )   insert temp values ('india'), ('bangladesh'), ('sri lanka'), ('pakistan')   select  t1.team + ' vs. ' + t2.team temp t1 cross join  temp t2  t1.team < t2.team   drop table temp      result     -----------     india vs. sri lanka     india vs. pakistan     bangladesh vs. india     bangladesh vs. sri lanka     bangladesh vs. pakistan     pakistan vs. sri lanka 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -