I am trying to run this syntax, but I get an error of
Msg 4145, Level 15, State 1, Line 9
An expression of non-boolean type specified in a context where a condition is expected, near 'SUM'.
And this is my syntax, just trying to conditionally execute a SUM() based off the criteria.
SELECT
CASE WHEN
SUM(case when raaa.EN = 'Yes' AND raaa.HR >= raaa.WT then raaa.WT end)
SUM(case when raaa.EN = 'Yes' AND raaa.HR <= raaa.WT then raaa.HR end)
SUM(case when raaa.EN = 'No' AND raaa.HR <= raaa.WT then raaa.HR end)
SUM(case when raaa.EN = 'No' AND raaa.HR >= raaa.WT then raaa.WT end)
END AS HR
FROM
ranaboveaboardabout raaa;
EDIT
I know that this will work, just can't seem to get syntax correct for the above
Select
CASE WHEN
SUM(raaa.field1) / SUM(CASE WHEN raaa.field2 < raaa.field1 THEN raaa.field2 ELSE raaa.field1 END) >= 16.23 THEN 20
ELSE SUM(raaa.field1) / SUM(CASE WHEN raaa.field2 < raaa.field1 THEN raaa.field2 ELSE raaa.field1 END)
END AS nestedSUM
FROM
ranaboveaboardabout raaa;