Kelvin Sparks
asked on
Return latest value
Hi Experts, I have a table - columns A,B,C are the primary key, column D is a date, and E is a varchar.
What I need is for eack PK, I want the data for column E returned for the latest date - leaving behing all earlier records for each PK. Try as I might, I just can't see it - been coding too long today.
Kelvin
What I need is for eack PK, I want the data for column E returned for the latest date - leaving behing all earlier records for each PK. Try as I might, I just can't see it - been coding too long today.
Kelvin
ASKER
Code below - syntax error at WHERE that occurs after the MaxValue - error message is: Incorrect syntax near the keyword 'WHERE'
(SELECT wr.Priority FROM AQD.qaoc_Work_Request wr INNER JOIN (SELECT WR_Period, WR_Type, WR_Number, MAX(Target_Start_Date) as Maxp FROM AQD.qaoc_Work_Request GROUP BY WR_Period, WR_Type, WR_Number) MaxValue
WHERE wr.WR_Period = MaxValue.WR_Period AND wr.WR_Type = MaxValue.WR_Type AND wr.WR_Number = MaxValue.WR_Number and wr.Target_Start_Date = MaxValue.Maxp)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Awesome - thanks for the prompt help
Open in new window