Home » SQL & PL/SQL » SQL & PL/SQL » group by & having clause (9i)
group by & having clause [message #288241] Sun, 16 December 2007 04:25 Go to next message
TechyWizard
Messages: 3
Registered: September 2007
Junior Member
Can any body please explain me why and how does the following query work:

select sum(deptno), deptno
from emp
having sum(deptno)> 100
group by deptno;

The above query gives the same output as:
select sum(deptno), deptno
from emp
group by deptno
having sum(deptno) > 100;

Thanks in advance.
Re: group by & having clause [message #288242 is a reply to message #288241] Sun, 16 December 2007 04:31 Go to previous messageGo to next message
Michel Cadot
Messages: 64140
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
There is no difference.
"group by" and "having" can be placed one after or before the other.

This is not an expert question but just a basic syntax one.

Regards
Michel
Re: group by & having clause [message #288249 is a reply to message #288242] Sun, 16 December 2007 07:12 Go to previous messageGo to next message
TechyWizard
Messages: 3
Registered: September 2007
Junior Member
Is the swapping allowed with only these two clauses?
Re: group by & having clause [message #288252 is a reply to message #288249] Sun, 16 December 2007 08:54 Go to previous messageGo to next message
Michel Cadot
Messages: 64140
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
No there are others, showed in the syntax graph in documentation.
SELECT

Regards
Michel
Re: group by & having clause [message #288269 is a reply to message #288252] Sun, 16 December 2007 20:07 Go to previous message
rleishman
Messages: 3724
Registered: October 2005
Location: Melbourne, Australia
Senior Member
START WITH and CONNECT BY are another that come to mind

Ross Leishman
Previous Topic: NO DATA Exception
Next Topic: PLS-00306 error
Goto Forum:
  


Current Time: Fri Dec 09 08:09:16 CST 2016

Total time taken to generate the page: 0.05691 seconds