相关语句如下:
select sum(run_time) totalruntime, (select count(1) count_times from TABLEA
where (COALESCE(model,-999) = 2 or COALESCE(model,-999) = 7)
and end_time >= To_Date('2008-09-09 00:00:00','yyyy-mm-dd hh24:mi:ss')
and start_time <= To_Date('2008-10-08 23:59:59','yyyy-mm-dd hh24:mi:ss') having 1=1) count_times from TABLEA having 1=1;在红色字体前出现红色的波浪线,提示错误:"ORA-00937: 非单组分组函数"
而如下语句就正确:
select sum(run_time) totalruntime, 1 s,sum(1) ss,avg(1) sss from TABLE_ONECUT_SK000001 having 1=1;搜索了不少地方都说是group by 的问题,我试了,好像不是。
我怀疑是里面的select查询语句被解释为一个数据集而不是类似数字结果的原因。
盼各位oracle达人给予解释
感谢!!
select sum(run_time) totalruntime, (select count(1) count_times from TABLEA
where (COALESCE(model,-999) = 2 or COALESCE(model,-999) = 7)
and end_time >= To_Date('2008-09-09 00:00:00','yyyy-mm-dd hh24:mi:ss')
and start_time <= To_Date('2008-10-08 23:59:59','yyyy-mm-dd hh24:mi:ss') having 1=1) count_times from TABLEA having 1=1;在红色字体前出现红色的波浪线,提示错误:"ORA-00937: 非单组分组函数"
而如下语句就正确:
select sum(run_time) totalruntime, 1 s,sum(1) ss,avg(1) sss from TABLE_ONECUT_SK000001 having 1=1;搜索了不少地方都说是group by 的问题,我试了,好像不是。
我怀疑是里面的select查询语句被解释为一个数据集而不是类似数字结果的原因。
盼各位oracle达人给予解释
感谢!!
一定要这么用的:select id,sum(zs) from test group by id
即前面出现的列一定要出现在group by 后面,否则报错,这个sql server\ sybase有区别
而加上group by后,提示错误:"ORA-00904:无效列名"
group by 字段 才行比如:select idx,sum(num) from table group by idx having idx>100;
问题已解决,不是用group by的。
只是将select的值,换成case了,里面的查询条件另外处理了。
还是感谢各位大虾的热心帮助。
这个错误通常是在使用GROUP BY 的时候没有把非SUM\COUNT等字段作为分组条件写入而产生的。