您好,感谢您的阅读,
我正在尝试使用相关子查询运行以下 SQL 查询,但它没有返回任何结果。我使用子查询只带回具有最低日期范围的结果。单独的查询和单独的子查询都可以正常工作。
有任何想法吗?我是否错误地链接了相关的子查询?
注意:相关子查询在查询的最后一行
谢谢你, Willz06jw
SELECT aaa."effective_time",
aaa."event_type_c",
"clarity_dep"."department_name",
"patient"."birth_date",
"patient"."pat_mrn_id",
"zc_ped_delivr_meth"."name",
"zc_ped_delivr_meth"."ped_delivr_meth_c",
aaa."department_id",
"clarity_dep"."department_id",
aaa."alt_event_type_c",
aaa."in_event_type_c"
FROM (("CLARITY"."clarity_adt" aaa
inner join "CLARITY"."clarity_dep" "CLARITY_DEP"
ON aaa."department_id" = "clarity_dep"."department_id")
inner join "CLARITY"."patient" "PATIENT"
ON aaa."pat_id" = "patient"."pat_id")
inner join "CLARITY"."zc_ped_delivr_meth" "ZC_PED_DELIVR_METH"
ON "patient"."ped_delivr_meth_c" =
"zc_ped_delivr_meth"."ped_delivr_meth_c"
WHERE ( "patient"."birth_date" >= To_date ('01-12-2012 00:00:00',
'DD-MM-YYYY HH24:MI:SS')
AND "patient"."birth_date" < To_date ('06-12-2012 00:00:00',
'DD-MM-YYYY HH24:MI:SS'
) )
AND ( aaa."department_id" = 236601
OR aaa."department_id" = 236703
OR aaa."department_id" = 236801
OR aaa."department_id" = 236901
OR aaa."department_id" = 237101
OR aaa."department_id" = 237201 )
AND aaa."event_type_c" = 3
AND aaa."effective_time" = (SELECT Min(bbb."effective_time")
FROM "clarity_adt" bbb
WHERE aaa."pat_id" = bbb.pat_id)