我有一个查询需要计算一些列的一些计数和一列的最大值的计数,然后按更多标准分组。
到目前为止,我有以下查询:
select
subj.inventoryNum as Inventory,
extract(month from subj.createDate) as month,
oolame.schoolCode as Code,
count(case when max(subVers.verNum) > 0 then 1 end) as deleted,
count(case when subVers.delDate is not null then 1 end) as changed
from
Subjects subj
inner join SubjectVersions subVers on subVers.subjFk = subj.subjId
inner join SchoolName oolame on oolame.oolameId = subj.oolameFk
group by
subj.inventoryNum,
extract(month from subj.createDate),
oolame.schoolCode;
它给了我以下错误:
ORA-00937: not a single-group group function
00937. 00000 - "not a single-group group function"
*Cause:
*Action:
Error at Line: 2 Column: 1