October 2, 2011 at 11:48 pm
Hi All,
Iam having a usersroles table with 2 columns USerID and RoleID.And when i ran the below query the output shows as below :
select UserID,(roleid) from dbo.Usersroles where UserID = 23
UserID RoleID
---------
232
233
which means that a single user is having 2 roleID's hence when we use the below query the output will be as follows using SUM:
select UserID , SUM(roleid) as RoleID from dbo.Usersroles where UserID = 23
group by UserID :
UserID RoleID
-----------
235
But i want the query to display the RoleID for the user as 3 as 2(roleid) already exists in 3(roleid) for single user
Thanks,
Ram
October 3, 2011 at 1:00 am
Please keep to one thread per subject
http://www.sqlservercentral.com/Forums/Topic1184288-391-1.aspx
October 3, 2011 at 1:52 pm
Is RoleID a bitmask? Or do higher numbered roles always include all lower-numbered roles?
Because you could just change the SUM to MAX in the latter case. It would return 3 in that case.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply