August 3, 2015 at 12:10 pm
I would like to display all the products with maximum SeqNo from the table below:
TABLE
ProductIDSeqNoBalance
111215
11135
111420
111510
12115
1212100
121325
121445
OUTPUT
ProductIDSeqNoBalance
111510
121445
August 3, 2015 at 12:24 pm
what have you tried so far?
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
August 3, 2015 at 12:54 pm
Check this for examples on how to solve the problem:
http://stackoverflow.com/questions/10591044/how-write-sql-to-select-the-maximum-value-in-each-group
August 3, 2015 at 1:09 pm
Use this
SELECT t.ProductID,tmp.MaxSeqNo,t.Balance
FROM YourTable t
JOIN
( SELECT ProductID , MAX(SeqNo) [MaxSeqNo]
FROM YourTable
GROUP BY ProductID
) tmp
ON tmp.ProductID = t.ProductID
AND tmp.MaxSeqNo = t.SeqNo
Igor Micev,My blog: www.igormicev.com
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply