Files
server/src/Sql/dbo/Views/CollectionUserUserDetailsView.sql

18 lines
549 B
MySQL
Raw Normal View History

2017-04-27 09:19:30 -04:00
CREATE VIEW [dbo].[CollectionUserUserDetailsView]
2017-04-03 12:27:02 -04:00
AS
SELECT
OU.[Id] AS [OrganizationUserId],
2017-04-27 09:19:30 -04:00
OU.[AccessAllCollections],
2017-04-03 12:27:02 -04:00
SU.[Id],
2017-04-27 09:19:30 -04:00
SU.[CollectionId],
2017-04-03 12:27:02 -04:00
U.[Name],
ISNULL(U.[Email], OU.[Email]) Email,
OU.[Status],
OU.[Type],
2017-04-27 09:19:30 -04:00
CASE WHEN OU.[AccessAllCollections] = 0 AND SU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly]
2017-04-03 12:27:02 -04:00
FROM
[dbo].[OrganizationUser] OU
LEFT JOIN
2017-04-27 09:19:30 -04:00
[dbo].[CollectionUser] SU ON OU.[AccessAllCollections] = 0 AND SU.[OrganizationUserId] = OU.[Id]
2017-04-03 12:27:02 -04:00
LEFT JOIN
[dbo].[User] U ON U.[Id] = OU.[UserId]