这个sql语句怎么改?
select a,b,c,d,e
sum(nvl(f,0))-sum(nvl(g,0))
where sum(nvl(f,0))-sum(nvl(g,0))> 0
group by a,b,c,d,e
这里有个错误说where后不能用分组函数,即sum(nvl(f,0))-sum(nvl(g,0))> 0不能用,为什么?应该怎么改?
高手帮忙
------解决方案--------------------select a,b,c,d,e
sum(nvl(f,0))-sum(nvl(g,0))
group by a,b,c,d,e
having sum(nvl(f,0))-sum(nvl(g,0))> 0
用having 就可以了