Hi
In below Select statement if it is false then i want to write another Select statement which should check that if indate exists between StartDate And Endate in Invoice it should also be Break else ''
C#
CASE WHEN ISNULL((SELECT TOP 1 DG.[OnBreak] FROM [SessionDeliveryParticipant] DG WHERE DG.[StudentID]=GP.[StudentID] AND DG.[SessionDeliveryCalendarID]=C.[SessionDeliveryCalendarID] AND DG.[Deleted]=0),0)=1 THEN 'Break' ELSE '' END AS [OnBreak]Thanks

Amit MohantyRank #112 · 20K reputationPosted Apr 11, 2023, 7:51 AM EDT
CASE WHEN ISNULL( (SELECT TOP 1 DG.[OnBreak] FROM [SessionDeliveryParticipant] DG WHERE DG.[StudentID]=GP.[StudentID] AND DG.[SessionDeliveryCalendarID]=C.[SessionDeliveryCalendarID] AND DG.[Deleted]=0),0)=1 OR ([InDate] BETWEEN [StartDate] AND [EndDate]) THEN 'Break' ELSE '' END AS [OnBreak]Naimish MakwanaRank #324 · 7.7K reputationPosted Apr 11, 2023, 5:46 AM EDT
Try this.
SELECT CASE WHEN ISNULL((SELECT TOP 1 DG.[OnBreak] FROM [SessionDeliveryParticipant] DG WHERE DG.[StudentID]=GP.[StudentID] AND DG.[SessionDeliveryCalendarID]=C.[SessionDeliveryCalendarID] AND DG.[Deleted]=0),0)=1 THEN 'Break' WHEN indate BETWEEN StartDate AND EndDate THEN 'Invoice' ELSE 'Another Select Statement' END AS [OnBreak] FROM [YourTable]Thanks