03Explorer
Technical User
I have a query returning any number of rows. For the sake of the user, I want a field that is just a counter (incremental field) to be displayed. Example below:
No. UserName
--- --------
1 Black, Bob
2 Cash, John
3 Doe, Jane
4 Caruba, Crystal
5 Dastardly, Richard
No rhyme or reason for the numbering other than a label for the row. I would like it to allow me to sort by UserName, but for simplicity and it works I am okay with the ordering by 'No.'
IF I were to do this in T-SQL:
No. UserName
--- --------
1 Black, Bob
2 Cash, John
3 Doe, Jane
4 Caruba, Crystal
5 Dastardly, Richard
No rhyme or reason for the numbering other than a label for the row. I would like it to allow me to sort by UserName, but for simplicity and it works I am okay with the ordering by 'No.'
IF I were to do this in T-SQL:
Code:
Select
ROW_NUMBER() OVER( ORDER BY SPG.PreGeneratedAutoID ) AS 'No.',
Surveyee = AM.LegalLastName + ', ' + AM.LegalFirstName
FROM
tblSurveysPreGenerated SPG
Left JOIN AssociateMaster AM ON SPG.Childid = AM.AssociateID
WHERE
PreGeneratedStatus = 2
ORDER BY 1 asc