gpt4 book ai didi

mysql - 2015 年未曾就诊的患者及其最后一次就诊日期

转载 作者:行者123 更新时间:2023-11-29 21:37:49 25 4
gpt4 key购买 nike

下面是提取从 2014/7/1 到今天没有见到提供者的患者的脚本。现在我想要一个新专栏,我可以在其中了解他们最后一次见面的日期是什么时候,我该怎么做?下面显示了带有列的表格。

如果您有任何疑问,请告诉我。

SELECT p.first_name, p.last_name, p.date_of_birth, 
p1.age, p.home_phone, p.cell_phone,
p.primarycareprovname, pe.enctimestamp,
pe.encnbr, p.city, p.zip, p.person_id
FROM person AS p
Inner join patient_ P1
on p.person_id=p1.person_id
LEFT OUTER JOIN Patient_encounter PE
ON pe.person_id =p.person_id
AND pe.enctimestamp BETWEEN '20140701' AND '20160131'

WHERE pe.person_id IS NULL
and p1.age>'59'
and p.city like '%Paris%'

Click on this Link to see the table with columns

最佳答案

您可以使用GROUP BYMAX():

SELECT p.first_name, p.last_name, p.date_of_birth, p1.age, p.home_phone, 
p.cell_phone, p.primarycareprovname,
MAX(pe.enctimestamp) as most_recent_date, p.city, p.zip, p.person_id
FROM person AS p Inner join
patient_ P1
on p.person_id = p1.person_id LEFT OUTER JOIN
Patient_encounter PE
ON pe.person_id = p.person_id AND
pe.enctimestamp BETWEEN '20140701' AND '20160131'
WHERE pe.person_id IS NULL and p1.age >'59' and p.city like '%Paris%'
GROUP BY p.person_id;

关于mysql - 2015 年未曾就诊的患者及其最后一次就诊日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34774617/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com