title: Unexpected Result with Case When statement
body: <p>This Case When in my query is returning unexpected results. Basically if the funding (Sub Query Case When) is under 3000 the value should be 3000. It is returning 0, i know this seems like a silly question but im really stuck on this one.</p>
  
  <p>Ive tried just executing the query on its own and it still returns 0. I have also tried this without the literals.</p>
  
  <pre><code>SELECT 
  Tax + StudentLoans AS 'Net Income Tax',
  GrossNI,
  CASE WHEN ed.EA_Indicator_CY = '0' THEN '0' ELSE 
  (SELECT CASE WHEN SUM(Funding) &gt; '3000' THEN '0' ELSE '3000' END FROM 
  PayrollRuns) END AS 'Employment Allowance',
  SMP AS 'SMP Recovered',
  NICompOnSMP AS 'SMP Comp',
  SPPA + SPPB AS 'SPP Recovered',
  SPPACompensation + SPPBCompensation AS 'SPP COMP',
  SAP AS 'SAP Recovered',
  SAPCompensation,
  SHPP_A + SHPP_B AS 'Shpp Recovered',
  SHPP_A_Compensation + SHPP_B_Compensation AS 'ShPP Comp',
  Apprenticeship_Levy_Due AS 'App Levy'
  FROM PayrollRuns pr
  CROSS JOIN [Employer Details] ed
  WHERE RunID = '1058'
  GROUP BY Tax, StudentLoans, GrossNI, SMP, NICompOnSMP, ed.EA_Indicator_CY, 
  SPPACompensation, SPPBCompensation, SAPCompensation, SHPP_A_Compensation, 
  SHPP_B_Compensation, SPPA, SPPB, SAP, Apprenticeship_Levy_Due, SHPP_A, 
  SHPP_B
  </code></pre>
  
  <p>My Employment Allowance column for this example should be coming back as 3000 but it is coming as 0. Any help would be greatly appreciated.</p>