我有下面的表格。
create table cricket(team1 varchar2(22),team2 varchar2(22)); select * from cricket
团队1团队2
INDIA SL SL AUS SA ENG ENG NZ AUS INDIA
在上面的表格中,我想显示参加比赛的球队的数量。例如
India 2 SL 1 Sa 1 Eng 2 Aus 2
juud5qan1#
你可以UNION ALL这两列,然后计算:
UNION ALL
WITH ALL_TEAMS AS ( SELECT TEAM1 AS TEAM FROM CRICKET UNION ALL SELECT TEAM2 FROM CRICKET ) SELECT TEAM, COUNT(1) AS NUMBER_OF_PLAYS FROM ALL_TEAMS GROUP BY TEAM
1条答案
按热度按时间juud5qan1#
你可以
UNION ALL
这两列,然后计算: