>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
If it's not broken, fix it until it is.
My Blog