on 03-20-2009 8:46 PM
Here's data for one employee:
Charge Date Work Date Segment
11/05/08 11/28/08 TPLNDD
11/07/08 11/09/08 TPLNDN
11/21/08 11/22/08 TPLNDA
11/26/08 11/29/08 TPLNDN
12/11/08 12/14/08 TPLNDN
I want to calculate the maximum "charge date" where segments in "TPLNDD", "TPLNDA". Then, once this date is selected (11/21/08), I want to pick/retrieve the date which corresponds to that record (11/22/08).
I would like to avoid creating a group for the maximum charge date, because I want to be able to drill down to the details and see all the records.
Thanks, Ada
Here you go..
Select emp_id, charge_date, Work_date, Segment from Employee_table e
where segment in ('TPLNDD', 'TPLNDA')
and charge_date = (select max(charge_date) from Employee_table where segment in ('TPLNDD', 'TPLNDA') and emp_id = e.emp_id)
Assuming you have the emp_id which is the primary key.
Thanks
-Azhar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.