oracle - What does the (2) mean in the below SQL query -


someone please explain why 2 used in below query.

select * employee e  where(2) = (select count(distinct(e1.sal))             employee e1             e.sal > e1.sal); 

the query returns employees salary higher 2 other salaries. parentheses misleading , isn't needed.

select * employee e  2 = (select count(distinct(e1.sal))             employee e1             e.sal > e1.sal); 

for example, given follow employees data:

       employee  salary        joe     $80,000        kate    $80,000        lee     $85,000        chris   $85,000        matt    $85,000        mike    $90,000        june    $90,000        jack    $100,000 
 query returns 
        mike    $90,000        june    $90,000       
  because 90,000 greater 80,000 , 85,000   notice jack not returned because salary greater 3 other salaries.  note there 5 employees salary less mike's , june's distinct keyword forces count 2. 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -