Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Posts
    16

    Unanswered: Prblem in getting the entry after group by usage.

    Hi,
    I want Group one table's (X - table) entries by "Y" attribute where "z" = 1
    After that
    In each grouping i have to Use the X entry that has the latest TIME

    for ex : i have a table Employee.

    I want to group Employee entries by emp_dept_id where emp_origin='INDIA'
    After that
    in each grouping i have to take that employee entry that has the latest time (the last updated time or max time )

    Can some one help me out how this can be obtained.

    Thanks..

  2. #2
    Join Date
    Nov 2008
    Posts
    1

    Try This..

    As per your example.

    Please try this Query and let me know your Observation.

    select emp_id,emp_dept_id from employee where emp_origin='INDIA' group by emp_id,emp_dept_id
    having max(date) > 'some_date';


    Thanks
    Murugan

  3. #3
    Join Date
    Nov 2008
    Posts
    16

    Thanks a Lot !!

    Hi Murugan,
    I tried the query.. Its working fine.. Excellent.. Got the exact expected output.

    Thanks a lot..

    Once again thanks a lot for helping me out within a shortspan of time..


Posting Permissions

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