Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query question
Message
 
 
To
12/11/2009 14:32:31
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01434430
Message ID:
01434577
Views:
41
>Sergey
>Thanks.
>I may have messed something up, but I'm getting two rows for each Sales Order
>I tried Naomi's and it works fine, so I'll use that one.
>Thanks again for your help.

Bill,

Sergey's code will work for you with this slight modification
SELECT t1.sono, t1.tcode, t1.tdate ;
	FROM mytable t1 ;
	WHERE t1.tdate = (SELECT MAX(tdate) FROM mytable t2 ;
					WHERE t1.sosno = t2.sono)
However, it is a slower method comparing with the others and it doesn't eliminate duplicates if you have the same max dates.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform