I have a table like this:
Item Serial_No Grade Size Location Date
CQ35 A243911 4 36 A 20110127
CQ35 A243911 4 36 B 20110329
CQ35 A243911 4 36 C 20110330
CQ38 A244567 3 38 A 20110127
CQ35 A244567 3 38 B 20110128
CQ38 A244567 3 38 C 20110129
CQ35 A244567 3 38 D 20110130
CQ40 A244568 3 41 A 20110127
CQ40 A244568 3 41 B 20110129
CQ36 A244570 2 37 A 20110125
The expected results shd look like this using SQL:
Item Serial_No Grade Size Location Date
CQ35 A243911 4 36 C 20110330
CQ35 A244567 3 38 D 20110130
CQ40 A244568 3 41 B 20110129
CQ36 A244570 2 37 A 20110125
I’m trying to extract the latest row of each Serial No.
Thanks
UPDATE : with date
The trick here is to do comparison in the range of Serial_No only, and the way to achieve this is with a Correlated Subquery as shown here.