How to check this in single statement ,if both condition satisfied then return true other wise false
SQL
case when (select COUNT(*) from NSP113_PayrollStatus_Divisionwise where PayrollStageId='DC811F70-B1D5-4910-8FCF-E6C83DD8FABB' and Status=1
and PayrollMonthid = (select NSP112PRP_ID from nsp112_payroll_period where NSP112PRP_Active_YN=1 ))>0 then 'True' else 'False' end as 'Initiated',
case when (select COUNT(*) from NSP113_PayrollStatus_Divisionwise where PayrollStageId='AA0B84E4-70C8-4E33-BD6E-C9F30B996D9D' and Status=0
and PayrollMonthid = (select NSP112PRP_ID from nsp112_payroll_period where NSP112PRP_Active_YN=1 ))>0 then 'True' else 'False' end as 'Submit'
Muhammad Imran AnsariRank #326 · 7.6K reputationPosted Dec 29, 2022, 2:36 PM EST
You can write the query like:
SELECT CASE WHEN (select COUNT(*) from NSP113_PayrollStatus_Divisionwise where PayrollStageId='DC811F70-B1D5-4910-8FCF-E6C83DD8FABB' and Status=1 and PayrollMonthid = (select NSP112PRP_ID from nsp112_payroll_period where NSP112PRP_Active_YN=1 ))>0 AND (select COUNT(*) from NSP113_PayrollStatus_Divisionwise where PayrollStageId='AA0B84E4-70C8-4E33-BD6E-C9F30B996D9D' and Status=0 and PayrollMonthid = (select NSP112PRP_ID from nsp112_payroll_period where NSP112PRP_Active_YN=1 ))>0 THEN 'True' ELSE 'False' END AS Result