Results 1 to 3 of 3

Thread: qryhelp

  1. #1
    Join Date
    Oct 2002
    Posts
    36

    Unanswered: qryhelp

    Hello


    how to retrieve the employees info who are earning more than the oldest employee.

    Thanks

  2. #2
    Join Date
    Jan 2003
    Posts
    16

    Re: qryhelp

    Originally posted by vadlamanibujji
    Hello


    how to retrieve the employees info who are earning more than the oldest employee.

    Thanks
    select * from emp where salary >
    (select salary from emp where age=(select max(age) from emp))

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: qryhelp

    Originally posted by umciggy
    select * from emp where salary >
    (select salary from emp where age=(select max(age) from emp))
    That works if only one employee has the max(age), otherwise it will give error:

    ORA-01427: single-row subquery returns more than one row

    In case there are 2 or more employees with max(age), you could specify the min(salary) or the max(salary):

    select * from emp where salary >
    (select max(salary) from emp where age=(select max(age) from emp))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •