I have 2 tables: user and licenseduser. The first one contains all the users and the second one contains only those users with a licenses (2 columns: useruid and subscriptionid).
Given a subscriptionId I have to display in a grid all the users and a boolean flag column indicating for each user if he/she has the subscription or not.
Example: The following query gives me that for the subscriptionId = 7.
select firstname, lastname, emailaddress, subscriptionid
from dbo.[user]
left join (select * from dbo.licensedUser where subscriptionid = 7) lu on dbo.[user].[Uid] = lu.useruid
However, this query is not useful for me because the executor program uses an ORM. I want to create a view (called myView) such that I can (or the ORM can) do this:
select firstname, lastname, emailaddress, subscriptionid
from myView
where subscriptionid = 7 or subscriptionid is null
Could you help me, please? Thank you in advance.