我有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