MSSQL Window Functions - ROWNUMBER OVER PARTITION BY Example
Window functions are functions that calculate a scalar value based on a window (set of records). This value is determined using the OVER instruction.
Example:
select regioncode, aolevel, offname,
row_number() over(partition by regioncode order by aolevel, offname) as rownum
from s_adr_fias
order by regioncode, aolevel, offname;
In this example, a query will be made where for each regioncode in the rownum field, numbering will be performed on the sorted values of aolevel, offname.
Comments (0)
No comments yet.