select sum(raw_ore) raw_ore ,(select sum(raw_ore0) from trv_daily where p_year=a.p_year ) lift_ore from trv_refine a where p_year=2024
尽管语句select sum(raw_ore0) from trv_daily where p_year=a.p_year ,只返回一个数值,系统提示“ORA-00937:不是单分组函数”
将子查询外面添加max等统计函数,即可解决该问题。
select sum(raw_ore) raw_ore ,max((select sum(raw_ore0) from trv_daily where p_year=a.p_year )) lift_ore from trv_refine a where p_year=2024
总结:在分组查询中,只允许2类列,分组依据列(group by)和分组查询列(sum、count)等。
标签:sum,查询,raw,分组,year,Oracle,ore,select From: https://www.cnblogs.com/imhuanxi/p/18115729