I want to use case in SQL, but also using the right group by
SELECT patientname, patientid, cancerstatus,
CASE
WHEN cancerstatus IS NOT NULL THEN 'In surgery'
WHEN cancerstatus IS NULL THEN 'no surgery needed'
END case
FROM database (nolock)
WHERE biopsydate BETWEEN '2020-08-25' AND '2020-08-26'
GROUP BY patientname, patientID
So I want to a case expression to put every patient who had cancer biopsy in categories of needing surgery or not, and I also want to group patients using patientID and name (those two criteras are must have).
It's showing error around the case part, what did I do wrong?