select
location,
home_team_name,
count(case when extract(year from match_date)='2018' and extract(month from match_date)=1 then 1 end) january_2018,
count(case when extract(year from match_date)='2018' and extract(month from match_date)=2 then 1 end) february_2018,
count(case when extract(year from match_date)='2018' and extract(month from match_date)=3 then 1 end) march_2018,
count(case when extract(year from match_date)='2018' then 1 end) Total
from match_results
union all
select
'total' as location,
'total' as home_team_name,
count(case when extract(month from match_date)=1 then 1 end) january_2018,
count(case when extract(month from match_date)=2 then 1 end) february_2018,
count(case when extract(month from match_date)=3 then 1 end) march_2018,
count(case when extract(year from match_date)='2018' then 1 end) Total
from match_results
group by location,home_team_name;
错误消息:ORA-00937:不是单组组函数。目前在 oracle live SQL 上运行它。
关于如何解决这个问题的任何想法?