Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Syntax help
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01400647
Message ID:
01400689
Views:
57
>Good point...closest down. Capture Date must be less than or equal to PO Date.

If it always less or equal, then the simple select will work
select * from (select TA.EDP, TB.Alert, Row_Number() 
OVER (Partition by TB.EDP ORDER BY Tb.CaptureDate DESC) as RowNum from TA 
INNER JOIN TB on TA.EDP = TB.EDP and TA.PoDate>=TB.CaptureDate) Derived where RowNum = 1
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform