A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
Hi @kasim mohamed ,
Please refer below and check whether it is helpful.
declare @condition varchar(100)
declare @AppLevel int=3 --define here 1,2,3
select @condition= Condition
from #Table2
where AppLevel=@AppLevel
if @condition='G2'
SELECT GroupID,b.value
FROM #Table1 a
outer APPLY OPENJSON (UserList) WITH (value NVARCHAR(100) '$.User') b
where GroupID=@condition
else if @condition='(G3-1 and G3-2) or G3-3'
SELECT GroupID,b.value
FROM #Table1 a
OUTER APPLY OPENJSON (UserList) WITH (value NVARCHAR(100) '$.User') b
where GroupID ='G3-1' or GroupID='G3-2' or GroupID='G3-3'
Best regards
Melissa
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues November--What can I do if my transaction log is full?
Hot issues November--How to convert Profiler trace into a SQL Server table