-
hi
how to find the salary of all the employees whos salary is > 2500 without using where clause.
jegan
Cheers!
OraKid.
-
You can use GROUP BY and HAVING clauses. Example:
SELECT ename, MAX(sal) salary FROM emp
GROUP BY ename
HAVING MAX(sal) > 2500;
Since employee and his sallary are in 1:1 relationship (or even in the same row as in this example), it is irrelevant which group function do you use. It aslo could have been MIN(), AVG(), SUM() etc instead of MAX().
HTH,
Jurij Modic
ASCII a stupid question, get a stupid ANSI
24 hours in a day .... 24 beer in a case .... coincidence?
-
Good solution, but HAVING is simply a grouped version of WHERE. :)
I'm wondering why in the world you need to find data but can't use the WHERE.
- Chris
-
hi,
I think this will also do (without max() function)
SELECT ename, sal salary FROM emp
GROUP BY ename,sal
HAVING sal > 2500;
P. Soni
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|