Distinct & Group By when used Analytic Function [message #612170] |
Mon, 14 April 2014 00:21 |
|
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi ,
Can you please explain? Why i am getting different results and what is the difference's of Distinct & Group By.
SQL> SELECT deptno, COUNT (*) OVER () AS empcount
2 FROM emp
3 GROUP BY deptno
4 /
DEPTNO EMPCOUNT
---------- ----------
10 3
20 3
30 3
SQL> SELECT DISTINCT deptno, COUNT (*) OVER () AS empcount
2 FROM emp
3 ORDER BY deptno
4 /
DEPTNO EMPCOUNT
---------- ----------
10 14
20 14
30 14
|
|
|
|
|