how to get the total records using LEVEL [message #620564] |
Mon, 04 August 2014 06:08 |
|
mist598
Messages: 1195 Registered: February 2013 Location: Hyderabad
|
Senior Member |
|
|
Hi all,
I need the total count of records?
SELECT MAX (sal)
FROM emp e
WHERE LEVEL <= 5
GROUP BY LEVEL
CONNECT BY PRIOR sal > sal
ORDER BY LEVEL
|
|
|
|
|
|
|
|
Re: how to get the total records using LEVEL [message #620573 is a reply to message #620572] |
Mon, 04 August 2014 07:10 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
mist598 wrote on Mon, 04 August 2014 17:25
Suppose i have output like above, then i need the max salary employees count,
I don't understand the purpose of your query.
Anyway, your query will always return the distinct rows based on SAL column due to this :
CONNECT BY PRIOR sal > sal
So the count of rows will be the number of distinct values of SAL.
But once again, I don't understand the purpose of your query.
|
|
|
|
Re: how to get the total records using LEVEL [message #620575 is a reply to message #620574] |
Mon, 04 August 2014 07:25 |
Lalit Kumar B
Messages: 3174 Registered: May 2013 Location: World Wide on the Web
|
Senior Member |
|
|
mist598 wrote on Mon, 04 August 2014 17:43Quote:So the count of rows will be the number of distinct values of SAL.
Ok, how to find the count of this?
Count of WHAT? You are yet to explain your requirement in words.
If you just need the count of distict SAL in emp table, then :
SQL> SELECT count(DISTINCT sal) cnt_sal FROM emp
2 /
CNT_SAL
----------
12
|
|
|
|
|