hi
how to find the salary of all the employees whos salary is > 2500 without using where clause.
jegan
Printable View
hi
how to find the salary of all the employees whos salary is > 2500 without using where clause.
jegan
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,
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