I know this is old, but in case anyone else finds it: There are a few problems with the code here. One is just extraneous parentheses, one is that there's "Total Premium" has a space in it...but the larger one is the logic of the CASE statement. Remember that CASE looks at a single row and returns a result for each row, so you can't have a SUM *inside* your CASE statement. The order must be reversed, like so: SUM(CASE WHEN t1.TOT_PREM IS NULL THEN 0 ELSE t1.TOT_PREM END) AS Total_Premium
... View more