Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
select * from emp m where(select COUNT(distinct salary) from emp s where s.salary>m.salary)=0
 

 
can any one tell me what is the execution flow
 
[edit]code block fixed[/edit]
Posted 15-Dec-12 22:06pm
Edited 15-Dec-12 22:14pm
Nelek49K
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

In SQL Server Management Studio, you can show the execution plan. Click Ctrl+M, or from the menu, choose 'Query|Include Actual Execution Plan'.
 
This will vary depending on your table structure (which indexes are available), your table contents (statistics), your server hardware (RAM, number of CPUs), and your server load (the server will invest more resources building a plan if more resources are available).
 
So the only one who can tell what is the execution plan is you.
 
Good luck,
Pablo.
  Permalink  
Comments
Abhishek Pant at 18-Dec-12 2:30am
   
Perfect,+5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I think that you can use MAX function...
 
For Example:
Select MAX(coloumn_name) from table_name;
 
Thanks.
  Permalink  
Comments
Sk. Tajbir at 16-Dec-12 14:16pm
   
5+
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You can use this query with Max function like Mr. Tarun said,
select * from emp where salary = (select Max(salary) from emp)
 
This is will give you a list of employees who have highest salary.
 
I hope this will work.
Thanks Smile | :)
  Permalink  
Comments
Tarun Y Mangukiya at 16-Dec-12 23:24pm
   
Ya.
The same Query we can use.
But I can't suggest him because he has to learn all this himself.
So, I just gave an example...
 
Thanks.
Sk. Tajbir at 17-Dec-12 2:07am
   
ok :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Gihan Liyanage 332
1 Sergey Alexandrovich Kryukov 230
2 ClimerChinna 222
3 vikinghunter 178
4 OriginalGriff 161
0 Sergey Alexandrovich Kryukov 8,373
1 OriginalGriff 7,112
2 CPallini 2,598
3 Richard MacCutchan 2,025
4 Abhinav S 1,788


Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 18 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100