Tags

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,


T – SQL 8

—Input

—————–

ID
1
2
3
4
5

CREATE TABLE List (  ID INT )

GO

INSERT INTO List(ID) VALUES (1),(2),(3),(4),(5)

SELECT * FROM List

—Find out the OUTPUT of the following query

SELECT L.ID List1 , L1.ID List2 FROM List L JOIN List L1 ON L.ID <> L1.ID

Output would be

List1 List2
2 1
3 1
4 1
5 1
1 2
3 2
4 2
5 2
1 3
2 3
4 3
5 3
1 4
2 4
3 4
5 4
1 5
2 5
3 5
4 5

Keep Learning.

Pawan Kumar

Advertisements