Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query question
Message
From
12/11/2009 14:34:55
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2008
Miscellaneous
Thread ID:
01434430
Message ID:
01434446
Views:
46
Perfect, Naomi!!!!!

Thanks a lot. My brain had just stopped working and that got it moving.



>
I have a table with sales order number (sono), Transaction Code (tcode) and transaction date (tdate) fields.
>There are multiple records for one Sales Order.
>I want to write a query that returns one record with the sono, tcode and tdate for the latest date for that sales order and I have a complete blank
>HELP!!

The simplest solution would be

select SoNo, tCode, tDate from (select SoNo, tCode, tDate,
row_number() over (partition by SoNo order by tDate DESC) as RowNum from Sales) X where RowNum = 1
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform