SELECT A+cuser_id AS [操作员编码],
cuser_name AS [操作员全名] ,
cdept AS [部门],
(SELECT TOP 1 EnumName
FROM AA_Enum
WHERE EnumType=NAdmin.UserType
AND EnumCode=0 AND LocaleId=dbo.UDF_GetLocaleID()) AS [用户类型],
1 FROM UA_User
WHERE iadmin=0
AND (iUserType=0 OR iUserType IS NULL)
AND (nState IS NULL OR nState=0)
union SELECT cuser_id AS [操作员编码],
cuser_name AS [操作员全名],
cdept AS [部门],
(SELECT TOP 1 EnumName FROM AA_Enum WHERE EnumType=NAdmin.UserType
AND EnumCode=1
AND LocaleId=dbo.UDF_GetLocaleID()) AS [用户类型],
1 FROM UA_User WHERE iadmin=0 AND iUserType=1 AND (nState IS NULL OR nState=0)
union SELECT cGroup_Id AS [操作员编码],
cGroup_Name AS [操作员全名], \ AS [部门],
角色 AS [用户类型] , 0
FROM UA_Group
where cgroup_id<>everyone