--Returns the rank of a result set:
SELECT StamTableId, StamTableStr, colIntA,
RANK() OVER (ORDER BY colIntA) as Rank_over
FROM StamTable
--Returns the rank of rows of a result set, without any gaps in the ranking:
SELECT StamTableId, StamTableStr, colIntA,
DENSE_RANK() OVER (ORDER BY colIntA) as Rank_over
FROM StamTable
--Returns the rank of rows within the partition of a result set, without any gaps in the ranking:
SELECT StamTableId, StamTableStr, colIntA,
RANK() OVER (PARTITION BY StamTableStr ORDER BY StamTableStr, colIntA) as Rank_over
FROM StamTable
RANK():
DENSE_RANK():
No comments:
Post a Comment