Ramco Ramco

Ramco Ramco

  • 444
  • 3.4k
  • 533.7k

Sql Query Issue

Jun 1 2023 12:53 AM

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


Answers (4)