运行select语句后,我得到以下值“see image”
我想要case
语句检查是否BloodPressureSystolic == 0
,如果是,请从BPSRSit
和BPSRSit
中提取值并添加然后将值添加到像这样的“115/65”临时表可以有人告诉我如何编写这样的案例。
这是我的select语句,我想将一个case语句添加到
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 )
答案 0 :(得分:4)
CASE WHEN BloodPressureSystolic = 0 AND BloodPressureDiastolic = 0 THEN
CAST(BPSRSit AS VARCHAR(10)) + '/' + CAST(BPDRSit AS VARCHAR(10)) END
答案 1 :(得分:0)
对于MySQL,您有两种使用CASE语句的选项。 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
关于你的问题你可以使用这样的东西:
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)