查询的数据需要增加一个行号
SELECT
ROW_NUMBER() OVER(ORDER BY witd_wages_area ,
witd_wages_type ,
witd_department_id ,
witd_give_out_time) '行号',
ISNULL(witd_wages_area, 0) witd_wages_area ,
witd_wages_type ,
witd_department_id ,
ISNULL(CONVERT(VARCHAR(7), witd_give_out_time, 23), '') witd_give_out_time ,
SUM(CONVERT(BIGINT, witd_id)) AS witd_id ,
SUM(CONVERT(BIGINT, witd_id) / 1000) AS witd_id_sub ,
COUNT(*) AS [count] ,
SUM(CONVERT(BIGINT, witd_taxsys_income_amount)) AS witd_taxsys_income_amount ,
SUM(CONVERT(BIGINT, witd_taxsys_tax_amount)) AS witd_taxsys_tax_amount ,
SUM(CONVERT(BIGINT, witd_income_amount)) AS witd_income_amount ,
SUM(CONVERT(BIGINT, witd_tax_amount)) AS witd_tax_amount ,
SUM(CONVERT(BIGINT, witd_diff_amount)) AS witd_diff_amount
FROM WAGES_INCOME_TAX_DIFFERENCE
WHERE 1 = 1
GROUP BY witd_wages_area ,
witd_wages_type ,
witd_department_id ,
witd_give_out_time
ORDER BY witd_wages_area ,
witd_wages_type ,
witd_department_id ,
witd_give_out_time