Interview Question
Country: United States
I already tried the query, the result is
Germany France
Spain France
Spain Germany
that do not make sense, any suggestion?
--Create Teams Table
CREATE table teams
(
id int,
name varchar(20)
)
insert into teams
(
id,
name
)
VALUES
(
1, -- id - int
'France' -- name - varchar
)
-- Insert sample data
insert into teams
(
id,
name
)
VALUES
(
2, -- id - int
'Germany' -- name - varchar
)
insert into teams
(
id,
name
)
VALUES
(
3, -- id - int
'Spain' -- name - varchar
)
--Generate fixtures between team
SELECT * from teams t CROSS join teams t2
WHERE t.id > t2.id
SELECT * from teams t CROSS join teams t2
WHERE t.id > t2.id
SELECT
- Anonymous April 18, 2012Team1.TEAM_NAME AS Team1,
Team2.TEAM_NAME AS Team2
FROM TEAM Team1
INNER JOIN TEAM Team2 ON Team1.TEAM_ID > Team2.TEAM_ID