07-31-2023, 09:56 AM
This query:
SELECT ROW_NUMBER() OVER(ORDER BY UserId) From Users WHERE UserName='Joe'
will return all rows where the `UserName` is `'Joe'` UNLESS you have no `UserName='Joe'`
They will be listed in order of `UserID` and the `row_number` field will start with 1 and increment however many rows contain `UserName='Joe'`
If it does not work for you then your `WHERE` command has an issue OR there is no `UserID` in the table. Check spelling for both fields `UserID` and `UserName`.
SELECT ROW_NUMBER() OVER(ORDER BY UserId) From Users WHERE UserName='Joe'
will return all rows where the `UserName` is `'Joe'` UNLESS you have no `UserName='Joe'`
They will be listed in order of `UserID` and the `row_number` field will start with 1 and increment however many rows contain `UserName='Joe'`
If it does not work for you then your `WHERE` command has an issue OR there is no `UserID` in the table. Check spelling for both fields `UserID` and `UserName`.