本文介绍了[不是问题]从具有相同出生日期的患者的每只蛾的表中找到身高,体重,患者ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 下表显示了患者及其身高体重表的视图。从这张表中我想为每位患者选择身高,体重,每个蛾的最大日期的患者ID,患者必须有相同的出生日期 PatientID 高度 MeasuredDate 出生日期.... 重量 1 150 12/12/2013 3/2/1987 60 1 150 2013年2月12日 1987年3月2日 64 1 150 24/12/2013 1987年3月2日 59 2 160 12/12/2013 1987年3月2日 65 2 160 19/12/2013 1987年3月2日 63 2 160 26 /二千零十三分之十二 1987年3月2日 60 2 160 2013年5月12日 1987年3月2日 66 1 150 2013年5月11日 1987年3月2日 67 1 150 2013年12月11日 1987年3月2日 66.5 1 150 19/11/2013 1987年3月2日 66 1 150 26/11/2013 1987年3月2日 67 2 150 2013年12月11日 1987年3月2日 67 2 150 2013年4月11日 1987年3月2日 68 2 150 19/11/2013 1987年3月2日 67 2 150 29/11/2013 1987年3月2日 68 3 160 12/12/2013 3 /1987分之2 65 3 160 19/12/2013 1987年3月2日 63 3 160 26/12 / 2013 1987年3月2日 60 3 160 2013年5月12日 1987年3月2日 66 4 160 26/12/2013 1989年3月2日 60 4 160 2013年5月12日 1989年3月2日 66 即结果是 PatientID 高度 MeasuredDate 出生日期.... 重量 1 150 24/12/2013 1987年3月2日 59 2 160 26/12/2013 1987年3月2日 60 1 150 26/11/2013 1987年3月2日 67 2 150 29/11/2013 1987年3月2日 68 3 160 26/12/2013 3 / 2/1987 60 患者4被省略,因为出生日期不同,每个人的最大日期每个月服用一个月,每月有价值 PLZ帮助table below shows a view of patient and their heightweight table . from this table i want to select height, weight, PatientId with max date in each moth for each patient ,Patient must have same birth date PatientIDHeightMeasuredDateBirthDate....Weight115012/12/2013 3/2/19876011502/12/20133/2/198764115024/12/20133/2/198759216012/12/20133/2/198765216019/12/20133/2/198763216026/12/20133/2/19876021605/12/20133/2/19876611505/11/20133/2/198767115012/11/20133/2/198766.5115019/11/20133/2/198766115026/11/20133/2/198767215012/11/20133/2/19876721504/11/20133/2/198768215019/11/20133/2/198767215029/11/20133/2/198768316012/12/20133/2/198765316019/12/20133/2/198763316026/12/20133/2/19876031605/12/20133/2/198766416026/12/20133/2/19896041605/12/20133/2/198966ie result is PatientIDHeightMeasuredDateBirthDate....Weight115024/12/20133/2/198759216026/12/20133/2/198760115026/11/20133/2/198767215029/11/20133/2/198768316026/12/20133/2/198760patient 4 is omitted since birth date is different and maximum date for each month is taken for each patient and there is value each monthPLZ help推荐答案 请先阅读我对该问题的评论。 试试这个: Please, read my comment to the question first.Try this:SELECT t1.PatientID, t2.Height, t1.MeasuredDate, t1.BirthDate, t2.WeightFROM ( SELECT PatientID, BirthDate, MONTH(MeasuredDate), MAX(MeasuredDate) AS MeasuredDate FROM PatiensTbl GROUP BY PatientID, BirthDate, MONTH(MeasuredDate) ) AS t1 INNER JOIN PatiensTbl AS t2 ON t1.PatientId = t2.PatientId AND t1.MeasuredDate = t2.MeasuredDate 这篇关于[不是问题]从具有相同出生日期的患者的每只蛾的表中找到身高,体重,患者ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-30 07:46