這是我的關係模型:SQL:最新紀錄
Request
------------------------------
RequestId
------------------------------
1
2
RequestState
------------------------------
RequestStateId | Name
------------------------------
10 | Received
20 | Processing
30 | Finsihed
Request_RequestState
-------------------------------------------------------------------
Request_RequestStateId | RequestId | RequestStateId | CreatedOn
-------------------------------------------------------------------
1 | 1 | 10 | 2010-01-01
2 | 1 | 20 | 2010-01-02
3 | 2 | 10 | 2010-01-15
每次請求的狀態變化,這種變化被存儲。 現在我需要按照當前狀態列出請求。 像「獲取當前狀態的所有請求=接收」。
到目前爲止,我只設法創建一個返回給定狀態的請求的查詢,但不管它是當前狀態還是舊的狀態......所以我不知何故需要使用CreatedOn來獲取最新/當前狀態。
任何幫助?提前致謝!