USE AdventureWorksOBP
--1
SELECT *, ROW_NUMBER() OVER (ORDER BY Prezime, Ime) FROM Kupac
ORDER BY Prezime, Ime

--2
SELECT *, ROW_NUMBER() OVER (PARTITION BY GradID ORDER BY Prezime, Ime) FROM Kupac
ORDER BY GradID, Prezime, Ime