例如,如果我有一个像EmpID,Empname,Country这样的表
输出应该是这样的
EmpId EmpName Country Serial No.
1 ABC India 1
2 BCD India 2
3 CMO India 3
4 DIS China 1
5 FGH China 2
6 FHI Singapore 1
7 XYZ Singapore 2
8 KLM Singapore 3
9 NOP Singapore 4
10 QRS Singapore 5
这里按价值分组是国家。
我自己找到了答案。以下查询可以。
SELECT EmpID , EmpName, Country , ROW_NUMBER() OVER(PARTITION BY
Country order by EmpName ) AS GroupSequence1 from Employee;
我们欢迎进一步的优化