我试图返回读数计数和实际读数(BP_SYS_LAST,BP_DIA_Last),这些读数在HTN_Watchlist.BP_SYS_LAST_DT之后的6个月内发生
我的子查询中的where子句是 其中BP_SYS_LAST_DT> HTN_Watchlist.BP_SYS_LAST_DT和 BP_SYS_LAST_DT< = DATEADD(m,6,HTN_Watchlist.BP_SYS_LAST_DT)
有关如何执行此操作的任何建议? 感谢
Select
HTN_Watchlist.LOC_NAME,
HTN_Watchlist.PAT_MRN_ID,
HTN_Watchlist.PAT_NAME,
HTN_Watchlist.BP_SYS_LAST,
HTN_Watchlist.BP_DIA_LAST,
HTN_Watchlist.BP_SYS_LAST_DT,
HTN_Watchlist.BP_DIA_LAST_DT
From
(
SELECT DISTINCT
CLARITY_LOC.LOC_NAME,
PATIENT.PAT_MRN_ID,
PATIENT.PAT_NAME,
DM_HYPERTEN_HX.BP_SYS_LAST,
DM_HYPERTEN_HX.BP_DIA_LAST,
DM_HYPERTEN_HX.BP_SYS_LAST_DT,
DM_HYPERTEN_HX.BP_DIA_LAST_DT
FROM CLARITY.dbo.PATIENT PATIENT
INNER JOIN CLARITY.dbo.DM_HYPERTEN_HX DM_HYPERTEN_HX ON PATIENT.PAT_ID=DM_HYPERTEN_HX.PAT_ID
INNER JOIN CLARITY.dbo.CLARITY_LOC CLARITY_LOC ON DM_HYPERTEN_HX.CUR_PRIM_LOC_ID=CLARITY_LOC.LOC_ID
WHERE (
DM_HYPERTEN_HX.BP_SYS_LAST > 140
or DM_HYPERTEN_HX.BP_DIA_LAST > 90
)
) As HTN_Watchlist