I wanted to find the max value of a column. I have the following table structure
OrderID TaskID SerialNo
1 1 2
1 2 3
2 1 1
2 2 2
From the above table i want the following result for every orderID and TaskID display the max value
By using MAX i am getting the OrderID and TaskID as well which is not my intended result. I am using SQL Server. How would i get the intended result?
Sounds like you're looking for something like this:
SELECT OrderID, TaskID, MAX(SerialNo)
GROUP BY OrderID, TaskID
ORDER BY OrderID, TaskID
Remove OrderID and/or TaskID from the SELECT if you don't want them displayed, but leave them in the GROUP BY.
Memphis PASS Chapter[/url]
All my SSC forum answers come with a money back guarantee. If you didn't like the answer then I'll gladly refund what you paid for it.
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]