rajagopalanseeth (6/29/2015)
Hi,I wanted to find the max value of a column. I have the following table structure
OrderIDTaskIDSerialNo
112
123
211
222
From the above table i want the following result for every orderID and TaskID display the max value
SerialNo
2
3
1
2
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?
Thanks,
Rajagopalan
Sounds like you're looking for something like this:
SELECT OrderID, TaskID, MAX(SerialNo)
FROM yourTable
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.
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]