Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 30th, 2007, 07:57 AM
mammu mammu is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2007
Posts: 3 mammu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 28 sec
Reputation Power: 0
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!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Retrieving the max date from a joined table


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT