Results 1 to 4 of 4

Thread: What is the value for MAX(SALARY)

  1. #1
    Geek_Guest
    Guest

    What is the value for MAX(SALARY)

    Question asked by visitor DBB
    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)?


  2. #2
    Junior Member
    Join Date
    Jan 2007
    Answers
    2

    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);


  3. #3
    Expert Member
    Join Date
    Apr 2006
    Answers
    124

    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.


  4. #4
    Contributing Member
    Join Date
    Apr 2007
    Answers
    58

    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!!!

    Regards,
    Anoop :)
    If its useful, dont forget to [COLOR="Red"]THANK[/COLOR] me :cool:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact