mikaelsnavy
3/15/2016 - 5:18 PM

Examples on how to use row_number and rank

Examples on how to use row_number and rank

SELECT
  ROW_NUMBER() OVER (ORDER BY ct_id) AS row_num,
  ROW_NUMBER() OVER (PARTITION BY source_id ORDER BY ct_id) AS partitioned_row_num,
  RANK() OVER (ORDER BY ct_id) AS row_num,
  RANK() OVER (PARTITION BY source_id ORDER BY ct_id) AS partitioned_row_num
FROM
  ct_pstor