- 論壇徽章:
- 0
|
問題:從log表中取出時間(end_time)最晚的表,從月初到現(xiàn)在
log表屬性說明
table_name,end_time,start_time
我的解決辦法:----1.找出要用到的結(jié)果集合
create table tmp_dw_log nologging as
select table_name,end_time,max(end_time) as max_endtime
from dw_log
where start_time > trunc(sysdate - 23)
group by table_name,end_time --1108
----2.從結(jié)果集合中取數(shù)據(jù)
select a.table_name,a.end_time,max(b.max_endtime)
from dw_log a,tmp_dw_log b
where a.end_time = b.end_time --1133
group by a.table_name,a.end_time |
得不到想要的結(jié)果,搞出來1000多條記錄,本來應該只有幾十來條?各位有什么好方法 |
|