|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Retrieving the max date from a joined table
hi,
I have two tables as given. In SQL srever 2005 Employees ----------------- >intEid (primary key) >intLeaveCredit LeaveApplications -------------------------- >intSlno (primary key) >intEid (Foreign key) >strTypeOfLeave ... >dteApplicationDate (datetime) >bolSanctioned (boolean) now, i need to be able to get max date of each intEid in LeaveApplications with bolSanctioned as false. I need all the fields in the LeaveApplications Table and intLeaveCredit from the Employees table, to be in the resulting joined table. this is what I have been doing... 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' ) it doesn't work! ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft SQL Server > Retrieving the max date from a joined table |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|