如何获取日期' start_ts'在查询过去30天 - oracle

时间:2017-09-01 17:11:36

标签: sql oracle

SELECT * FROM
(
    SELECT trunc(start_ts) ,STATUS 
    FROM table1
)
PIVOT (
    COUNT(STATUS) FOR STATUS in ('ERROR' error, 'COMPLETED' Completed)
);

1 个答案:

答案 0 :(得分:0)

条件start_ts > sysdate-30会将start_ts限制为持续30天。

SELECT * FROM
(
    SELECT trunc(start_ts) ,STATUS 
    FROM table1 where start_ts > sysdate-30
)
PIVOT (
    COUNT(STATUS) FOR STATUS in ('ERROR' error, 'COMPLETED' Completed)
);