• Hi,

    Try:

    with CTE as

    (

    select

    bookid,

    ROW_NUMBER() OVER(PARTITION BY Location ORDER BY bookid DESC) as RowNum

    from MyTable

    )

    delete from MyTable

    from MyTable as t

    join CTE as c

    on c.bookid = t.bookid and c.RowNum > 1

    Hope this helps.