任何人都可以帮助解决 SQL SERVER 2008 中的这个问题。我想将 seq 编号放在选择查询结果中的分组项目中。
select a.grade, a.name, a.age, seqno
from tab A join tab B on A.id = B.id
[group based on Grade column]
结果应如下所示。
SeqNo Grade Name Age
----- ----- ---- ---
1 A abc 23
2 A xyz 7
1 B dfg 34
2 B sxd 23
3 B vvv 56
在下面的查询中,我如何加入第二个表并使用“加入”
SELECT ROW_NUMBER() OVER ( PARTITION BY [a.Grade] ORDER BY [a.Name]) AS 'SeqNo',
[a.Grade], [a.Name], [a.Age]
FROM Employee a WITH (NOLOCK)
ORDER BY [a.Grade],[a.Name]