Results 1 to 3 of 3

Thread: Group by clause

  1. #1
    Join Date
    Mar 2004
    Posts
    80

    Unanswered: Group by clause

    I need to fetch every first employee sorted on their last name from every department in an organization . So I have grouped by organization but how do I select the first row sorted by last name in Oracle?

  2. #2
    Join Date
    May 2005
    Posts
    38
    SELECT * from ( SELECT * from employee group by org order by last_name) where rownum < 2

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    To get just the last names:
    Code:
    select org_id, max(last_name)
    from employees
    group by org_id;
    If you want additional data from the employees table then you can do this:
    Code:
    select * from employees where (org_id, last_name) in
    ( select org_id, max(last_name)
      from employees
      group by org_id
    );

Posting Permissions

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