我有一个表中的SQL Server数据表与闵数据和Max:查询的2个属性
这里是结构
Name Problem Date IsCurrent
-----------------------------------------
John Fever 22-06-2015 1
Davis High BP 20-06-2015 0
John Headache 25-05-2105 0
John Fever 20-05-2015 1
Davis High BP 10-05-2015 1
我想在查询该表1名时间。对于例如如果我查询Problem
与John
。
我的结果集应该是
1. Fever 20-05-2015 (Min Date of the Problem) 1 (IsCurrent status as of the latest date)
2. Headache 25-05-2015 0
为Davis
结果集将是
1. High BP 10-05-2015 (Min Date of the Problem) 0 (IsCurrent status as of the latest date)
由于两个Min Date
和Max Date
这里是必需的,哪些将是我最优化的查询?
在查询中通过名称和问题列进行分组。 –