Sql server - Get last occurrence of an XML attribute -


i have following data in table enter image description here

and i'm trying write query return row contains last occurrence of given id. example :- in case of example above, it'll return 2 rows (id#282 & id#266)

how go writing this?

with t1      (select *,                 xml.value(( '(//customer/@id)[1]' ), 'int') customerid            yourtable),      t2      (select *,                 row_number() on (partition customerid order id desc) rn            t1) select id,        customerid,        xml   t2  rn = 1  

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -