Reputation: 1
Coding in SQL Server 2008
I have a list of patients and associated result values. I need to filter patients based on a specific result value (MMRC) being null or not null. Each patient has multiple results, but only one needs to be evaluated for this.
Example:
Patient SMITH
Result Value 1
Result Value 2
Result Value 3
MMRC = 2
Patient JONES
Result Value 1
Result Value 2
Result Value 3
MMRC = NULL
I want to "flag" Patient SMITH as "Pulmonary" (MMRC is not null) and Patient JONES as "Cardiac" (MMRC is null) so that I can use that "Flag" as a parameter in my crystal report.
Upvotes: 0
Views: 31
Reputation: 48187
Looks like you need a CASE
SELECT CASE WHEN MMRC IS NULL
THEN 'Cardiac'
ELSE 'Pulmonary'
END condition
FROM Patient
Upvotes: 2