2015-10-17 29 views
0

我有一個像下面這樣的'table1'表。我想要找到位於兩個L之間的所有H狀態字段。上述標準的輸出應該是03/07/15,08/07/15和09/07/15。我該如何解決這個問題?如何比較查詢中同一字段內的值?

date  Status 
01/07/15 A 
02/07/15 L 
03/07/15 H 
04/07/15 L 
05/07/15 H 
06/07/15 A 
07/07/15 L 
08/07/15 H 
09/07/15 H 
10/07/15 L 
+0

這不是你在這裏問了同樣的問題? http://stackoverflow.com/questions/32942892/how-to-compare-values-between-rows-in-access-query – Andre

+0

不一樣,但相似..... –

+0

所以你應該從答案中添加SQL並解釋它無法處理的情況,所以我們可以建立它。 – Andre

回答

-1

試試這個

select date, status from table1 where status = 'H' and date between (select MIN(date) from table1 where status = 'L') and (select MAX(date) from table1 where status = 'L') 
+0

這不起作用,因爲它只查看狀態爲L. – Andre

+0

的全局MAX和MIN日期,所以你想要什麼? –