hi,
I have two tables as given created in SQL srever 2005
Employees
-----------------
>intEid (primary key)
>intLeaveCred it
LeaveApplicatio ns
--------------------------
>intSlno (primary key)
>intEid (Foreign key)
>strTypeOfLea ve
...
>dteApplication Date (datetime)
>bolSanctione d (boolean)
now, i need to be able to get max date of each intEid in LeaveApplicatio ns with bolSanctioned as false. I need all the fields in the LeaveApplicatio ns Table and intLeaveCredit from the Employees table, to be in the resulting joined table.
this is what I have been doing...
I have two tables as given created in SQL srever 2005
Employees
-----------------
>intEid (primary key)
>intLeaveCred it
LeaveApplicatio ns
--------------------------
>intSlno (primary key)
>intEid (Foreign key)
>strTypeOfLea ve
...
>dteApplication Date (datetime)
>bolSanctione d (boolean)
now, i need to be able to get max date of each intEid in LeaveApplicatio ns with bolSanctioned as false. I need all the fields in the LeaveApplicatio ns Table and intLeaveCredit from the Employees table, to be in the resulting joined table.
this is what I have been doing...
Code:
select e.intEid, e.intLeaveCredit, l.strTypeOfLeave, l.dteFrom, l.dteTo, l.strReason, l.dteApplicationDate, l.bolSanctioned from Employees e join LeaveApplications l on e.intEid = l.intEid where l.dteTo = (select max(dteTo) from LeaveApplications where bolSanctioned = 'false' )
Comment