ora-00937

Maximum of averages

一世执手 提交于 2019-12-22 08:37:00
问题 I'm supposed to get every departments average wage and only show the department with the highest average wage. I figured out this query, but it doesn't work. Anyone got some ideas? SELECT department, max(avg(wage)) FROM employees GROUP BY department; I get this error: ERROR at line 1: ORA-00937: not a single-group group function 回答1: Without CTEs you can do: Select Z.Department, Z.AvgWage From ( Select Department, Avg(Wage) AvgWage From Employees Group By Department ) As Z Where AvgWage = (

sql - ORA-00937: not a single-group group function

房东的猫 提交于 2019-12-11 12:05:53
问题 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

Maximum of averages

帅比萌擦擦* 提交于 2019-12-05 15:59:00
I'm supposed to get every departments average wage and only show the department with the highest average wage. I figured out this query, but it doesn't work. Anyone got some ideas? SELECT department, max(avg(wage)) FROM employees GROUP BY department; I get this error: ERROR at line 1: ORA-00937: not a single-group group function Without CTEs you can do: Select Z.Department, Z.AvgWage From ( Select Department, Avg(Wage) AvgWage From Employees Group By Department ) As Z Where AvgWage = ( Select Max(Z1.AvgWage) From ( Select Department, Avg(Wage) AvgWage From Employees Group By Department ) Z1 )

How to resolve ORA-00937: not a single-group group function when calculating percentage?

南楼画角 提交于 2019-12-01 16:38:44
问题 I'm trying to get a percentage of the itemid that are available in a certain area. Using my query, I get an error ORA-00937: not a single-group group function All the details: I have these two tables: ALLITEMS --------------- ItemId | Areas --------------- 1 | EAST 2 | EAST 3 | SOUTH 4 | WEST CURRENTITEMS --------------- ItemId --------------- 1 2 3 and want this result: --------------- Areas| Percentage --------------- EAST | 50 --because ItemId 1 and 2 are in currentitems, so 2 items