Results 1 to 3 of 3

Thread: Select the Employee names who held max positions

  1. #1
    Junior Member
    Join Date
    Oct 2006
    Answers
    2

    Select the Employee names who held max positions

    Write a query for this..!! i want to select the employee names who held max positions in the company. I want to display empname, positioncount. I have 2 tables where position, empno are in one table (jobhistory) and empno, empnames are in another table(employee). Select surname from employee where employee.empno in( select empno from jobhistory group by empno having count(*)=(select max(count(position)) from jobhistory group by empno)) the above query returns the empnames who held max positions in the company but i want to display the position count aswell..!!


  2. #2
    Expert Member
    Join Date
    Jun 2006
    Answers
    410

    Re: Select the Employee names who held max positions

    Try this query,

    Select a.surname,b.positions
    from employee,( select empno,count(*) positions
    from jobhistory
    group by empno having count(*)=(select max(count(position)) from jobhistory group by empno)) b
    where a.empno=b.empno


  3. #3
    Junior Member
    Join Date
    Oct 2006
    Answers
    2

    Re: Select the Employee names who held max positions

    Quote Originally Posted by jamesravid View Post
    Try this query,

    Select a.surname,b.positions
    from employee,( select empno,count(*) positions
    from jobhistory
    group by empno having count(*)=(select max(count(position)) from jobhistory group by empno)) b
    where a.empno=b.empno

    James, Can U be more clear Pl..!! And I want the Count of Positions held and not the name of the position

    Last edited by brl51274; 04-12-2007 at 04:42 AM.

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