Hi
I have below sql query . I want if count of current query = 0 then it should check the condition where V.Isactive = 0 else with V.isactive = 1
Current query
(SELECT TOP 1 V.[LastSessionTentativeDate] FROM [View_StudentSubscription] V WHERE V.IsActive = 1 AND V.StudentID = t.StudentId AND V.SubscriptionStatus = 'Active' AND V.DummySubscription = '' ORDER BY V.LastSessionTentativeDate DESC) [LastSessionTentativeDate],
(SELECT TOP 1 V.[LastSessionTentativeDate] FROM [View_StudentSubscription] V WHERE V.IsActive = 0 AND V.StudentID = t.StudentId AND V.SubscriptionStatus = 'Active' AND V.DummySubscription = '' ORDER BY V.LastSessionTentativeDate DESC) [LastSessionTentativeDate],
Thanks
Rajkiran SwainPosted Jun 1, 2023, 6:27 PM
Amit MohantyPosted Jun 1, 2023, 5:57 AM
Check this:
Vishal JoshiPosted Jun 1, 2023, 5:29 AM
Hello Ramco
You can get expected results using different ways like you can write a stored procedure or you can write conditions in a programming language like C#.
Thank you
Vishal
Mudzakkir TohaPosted Jun 1, 2023, 2:40 AM
do you want do if else in the sql?
if count sql 1 have rows, do sql1.
else do sql2?