Home » SQL & PL/SQL » SQL & PL/SQL » having clause is working before group by , why ? (oracle 10g)
having clause is working before group by , why ? [message #634789] Mon, 16 March 2015 03:23 Go to next message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

i saw a guy using having clause before group by function, and his code was working when it is supposed to give syntax error.
he used below query:-

select deptno,avg(sal)
from emp
having avg(sal)>2000
group by deptno


i want to know the reason why above code is working , please help.

Re: having clause is working before group by , why ? [message #634790 is a reply to message #634789] Mon, 16 March 2015 03:47 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
From the SQL Reference,Quote:
If you specify both GROUP BY and HAVING, then they can appear in either order.
Re: having clause is working before group by , why ? [message #634798 is a reply to message #634790] Mon, 16 March 2015 06:08 Go to previous message
jgjeetu
Messages: 373
Registered: July 2013
Location: www.Orafaq.com/Forum
Senior Member

Thanks @jw Smile
Previous Topic: Query execution changes in oracle 11.2.0.4.5 version
Next Topic: Why "SQL command not properly ended" error on one and not on the other?
Goto Forum:
  


Current Time: Fri Mar 29 03:25:40 CDT 2024