Reputation: 666
After I run my select statement I get the following values "see image"
I would like to have a case
statement to check if BloodPressureSystolic == 0
and if so, then pull the values from BPSRSit
and BPSRSit
and add then add the values to the temp table like this "115/65" can someone show me how to write a case like that.
Here is my select statement that I would like to add a case statement to
SELECT ad.ApptDate ,
ISNULL(v.Temperature, 0) AS Temperature ,
ISNULL(v.PS, 0) AS PerfStatus ,
v.*
FROM vitals v ,
AppointmentData ad
WHERE v.PatientId = 11
AND ad.ApptId = v.ScheduleId
AND ad.ApptDate < GETDATE()
AND ad.StatusId NOT IN ( 3, 8 )
Upvotes: 2
Views: 432
Reputation: 1
For MySQL you have two options in using the CASE statment. http://dev.mysql.com/doc/refman/5.0/en/case.html
CASE [case value] WHEN [value] THEN [output] END
OR
CASE WHEN [search conditions] THEN [output] END
About you question you could use something like this:
select ad.ApptDate ,
ISNULL(v.Temperature, 0) as Temperature,
ISNULL(v.PS, 0) as PerfStatus,
v.*,
CASE WHEN (BloodPressureSystolic = 0 AND BloodPressureDiastolic = 0) THEN CONCAT(BPSRSit, "/", BPDRSit) END AS myOutput
from vitals v,AppointmentData ad
Where v.PatientId = 11
And ad.ApptId = v.ScheduleId
and ad.ApptDate < GETDATE()
and ad.StatusId not in (3,8)
Upvotes: 0
Reputation:
CASE WHEN BloodPressureSystolic = 0 AND BloodPressureDiastolic = 0 THEN
CAST(BPSRSit AS VARCHAR(10)) + '/' + CAST(BPDRSit AS VARCHAR(10)) END
Upvotes: 4