我有3個表來加入以獲取table1.code,table1.series,table2.entry_date,table3.title1 並且我試圖獲取最近的非null table1.title1按table1.code和table1.series分組。在select語句中獲取每個組的最近條目
select table1.code, table1.series, max(table2.entry_date), table3.Title1
from table3 INNER JOIN table2 ON table3.ID = table2.ID
INNER JOIN table1 ON table2.source_code = table1.code
where table3.Title1 is not NULL
group by table1.code, table1.series, table3.Title1
似乎給了我一個非null的title1而不是最近的所有條目。我應該如何構建查詢來挑選最新版本的Title1代碼&系列?
你能否提供一些樣本數據? – DForck42 2010-05-07 15:33:11