我有一個表中的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
這裏是必需的,哪些將是我最優化的查詢?
在查詢中通過名稱和問題列進行分組。 –