使用JOINS在SQL中获取最大插入日期

时间:2016-08-02 16:18:21

标签: sql actian

我有一个表格列表:

select tableList
from information_schema.tables

这些表中的每一个都有一个插入日期。我想得到每个表的max(insertdate),并将插入日期放在它旁边,如:

Column1   Column2
table1    MaxInsertDateTable1
table2    MaxInsertDateTable2
table3    MaxInsertDateTable3
table4    MaxInsertDateTable4

有办法做到这一点吗?我正在使用MPP数据库:

http://www.actian.com/products/big-data-analytics-platforms-with-hadoop/matrix-mpp-analytics-databases/

1 个答案:

答案 0 :(得分:0)

我会设想一个查询,例如:

select 'table1' as column1, max(insertdate) as column2 from table1 union all
select 'table2' as column1, max(insertdate) as column2 from table2 union all
select 'table3' as column1, max(insertdate) as column2 from table3 union all
select 'table4' as column1, max(insertdate) as column2 from table4;