我有一个查询,我想要一列,因为SR_No
它应该从1开始
以下是我的查询
SELECT
top 2
userName,
Party_name,
Ref_No,
Ref_date,
doc_date,
Last_Action_date,
RAName,
COUNT(Doc_No) AS CountofDocNo,
Document_Type,
RA1_Email
FROM #MainTempTable
GROUP BY RAName,
userName,
Document_Type,
RA1_Email ,Party_name,Ref_No,
Ref_date, doc_date,Last_Action_date
order by RAName
如何从1开始序列号。
我尝试过,Row_NUM()
但不是从1开始。
更新
我尝试了Madhivnan的解决方案,但对第二个查询没有用
SELECT
top 2
row_number() over (order by (select 0)) as SR_No,
UserName,
RAName,
Party_Name,
Ref_No,
Ref_date,
doc_date,
Last_Action_date,
Document_Type,
Doc_No,
No_Of_Days_Doc_Pending,
UserEmail,RA1_Email
FROM #MainTempTable order by UserName
试试这个
SELECT
top 2 row_number() over (order by (select 0)) as SR_No,
userName,
Party_name,
Ref_No,
Ref_date,
doc_date,
Last_Action_date,
RAName,
COUNT(Doc_No) AS CountofDocNo,
Document_Type,
RA1_Email
FROM #MainTempTable
GROUP BY RAName,
userName,
Document_Type,
RA1_Email ,Party_name,Ref_No,
Ref_date, doc_date,Last_Action_date
order by RAName
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句