How can I add a serial number for the following query. I want final result to be displayed with the serial number.
select
EP.FirstName
, Ep.LastName
, [dbo].[GetBookingRoleName](ES.UserId,EP.BookingRole) as RoleName
from [3rdi_EventParticipants] as EP
inner join [3rdi_EventSignup] as ES on EP.SignUpId = ES.SignUpId
where EP.EventId =13
and开发者_JS百科 userid in (
select distinct userid from userroles
where roleid not in(19, 20, 21, 22) and roleid not in(1,2))
Here is the query that tags a serial row number based on the First Name:
SELECT Row_number() OVER(ORDER BY (SELECT 1)) AS 'Row Number',
ep.firstname,
ep.lastname,
[dbo].[Getbookingrolename](es.userid, ep.bookingrole) AS rolename
FROM [3rdi_EventParticipants] AS ep
INNER JOIN [3rdi_EventSignup] AS es
ON ep.signupid = es.signupid
WHERE ep.eventid = 13
AND userid IN (SELECT DISTINCT userid
FROM userroles
WHERE roleid NOT IN( 19, 20, 21, 22 )
AND roleid NOT IN( 1, 2 ))
EDIT: Removed the ORDER BY on EP.FirstName, Ep.LastName
精彩评论