Simple Query Problem
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Simple Query Problem

  1. #1
    Join Date
    Dec 2000
    Location
    Virginia, USA
    Posts
    455
    I have a simple query problem,

    If I write following query it works fine

    Select max(hiredate), deptno from emp
    group by Deptno;

    It gives me three record which is fine, Now I also want the Sal and empno of the records, How Do I do it?

    Thanks in advance

    [Edited by irehman on 01-15-2002 at 11:15 PM]

  2. #2
    Join Date
    Jan 2002
    Posts
    1

    Arrow solution for your simple query problem

    [QUOTE]Originally posted by irehman
    [B]I have a simple query problem,

    If I write following query it works fine

    Select max(hiredate), deptno from emp
    group by Deptno;

    It gives me three record which is fine, Now I also want the Sal and empno of the records, How Do I do it?


    Answer:

    Try to execute below query your problem will be solved..

    select hiredate,deptno,empno,sal from emp
    where (hiredate,deptno) in(select max(hiredate),deptno from emp group by deptno);

    with regards
    Mathur


Posting Permissions

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


Click Here to Expand Forum to Full Width