我有2个数据表,我需要回答以下问题
“哪些患者在 2018 年有药房保险但从未配过处方?”
--处方索赔数据集--
claim_id hvid date_service
191592860 934968097 1/15/2018
185972358 69871984 1/10/2018
805452300 405853776 1/5/2020
185972358 220235342 1/15/2019
--覆盖数据集--
hvid date_start date_end benefit_type
347327518 8/1/2008 7/31/2019 MEDICAL
934968097 10/22/2009 10/31/2017 PHARMACY
69871984 8/1/2004 12/31/2018 PHARMACY
尝试编写嵌套查询但无法获取任何结果
SELECT c.hvid
FROM Coverage c
LEFT JOIN PrescriptionClaims p ON c.hvid = p.hvid AND YEAR(p.date_service) = 2018
WHERE c.benefit_type = 'PHARMACY'
AND YEAR('2018-01-01') BETWEEN YEAR(c.date_start) AND YEAR(c.date_end)
AND p.hvid IS NULL;