I think above solution will not work as you need to compare only first four digit of product, try using this one:
select id, product, date
from (
select id, product, date,left(product,4), row_number() over ( partition by left(product,4) order by date desc ) rnum
from ur_table ) temp
where rnum = 1
Main Topics
Browse All Topics





by: rrjegan17Posted on 2009-07-03 at 00:45:30ID: 24770650
Hope this helps:
P.S: works only for SQL Server 2005
Select allOpen in new window