Here's the issue: When a Patient comes into the doctor's office, they can have their blood pressure taken 3 times. The first time is bp1; the second is bp2 and the last time is bp3.
I need to find the last time a patient had their blood pressure checked and what it was. I thought I could use COALESCE(bp3,bp2,bp1). However; the system doesn't always make the unused fields NULL. Sometimes, they're empty.
An example of the data would be:
PatientID bp1 bp2 bp3
12345 140/90 134/30
12346 NULL 128/68 NULL
Then, I thought I'd use COALESCE(NULLIF(bp3,bp2),bp1) but that isn't working because sometimes the database shows NULL for bp1 or NULL for bp1 and bp3, but there's a blood pressure in bp2.
Anyone have any ideas on how to resolve this?
Thanks!