What is the value for MAX(SALARY)
[B]Question asked by visitor DBB[/b]
select Name, MAX(SALARY)
from EMP
where DEPT 'xxxx';
My question here is above query contains obvious error; it is missing '='. however in this case sql will display error message, but what is the value for MAX(SALARY) (before fixing the error)?
Re: What is the value for MAX(SALARY)
Try this:
Select Name, DeptNo, sal as maxsal
from emp
where sal=(select max(sal) from emp);
Re: What is the value for MAX(SALARY)
there is another query to obtain the max salary :
Select Name, DeptNo, sal as maxsal from emp order by sal desc limit 0,1;
this displays the record having maximum salary.
Re: What is the value for MAX(SALARY)
Select Name, DeptNo, sal as maxsal
from emp
where sal=(select max(sal) from emp);
I think, it is the good one in terms of resource usage..
Select Name, DeptNo, sal as maxsal from emp order by sal desc limit 0,1;
This will use a lot of resources for sorting etc. if the database is really big one!!!