Mark Wilson
asked on
Maximum Value
SQL 2008
I have a table with some example data as follows
Task Audit Status
1 22 Draft
1 23 Pending
1 24 Complete
2 25 Draft
2 26 Pending
I simple want to bring out the maximum audit value for each tasks
Results would be
Task Status
1 Complete
2 Pending
Any help would be appreciated
I have a table with some example data as follows
Task Audit Status
1 22 Draft
1 23 Pending
1 24 Complete
2 25 Draft
2 26 Pending
I simple want to bring out the maximum audit value for each tasks
Results would be
Task Status
1 Complete
2 Pending
Any help would be appreciated
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
FROM (
SELECT Task, Status,
ROW_NUMBER() OVER(PARTITION BY Task ORDER BY Audit DESC) AS row_num
FROM a_table
) AS derived
WHERE
row_num = 1
ORDER BY Task