sql - Update a column paratitioned by another column -
i have table 2 columns this:
basedon line mm2013000028 mm2013000028 mm2013000028 mm2013000029 mm2013000030 mm2013000030 the line number blank should be:
basedon line mm2013000028 001 mm2013000028 002 mm2013000028 003 mm2013000029 001 mm2013000030 001 mm2013000030 002
this how row number (partitioned baseon) , update result set:
with r_sometable ( select * , row_number() over(partition baseon order baseon) rnk sometable ) update r_sometable set line = rnk go you can @ question more details:
http://social.msdn.microsoft.com/forums/sqlserver/en-us/ee06f451-c418-4bca-8288-010410e8cf14/update-table-using-rownumber-over
Comments
Post a Comment