首页 > 代码库 > Oracle下按分钟多表查询
Oracle下按分钟多表查询
select to_char(SIGNDATE,‘yyyy-MM-dd HH24:mi‘) ,count(*) from (
SELECT * FROM (select ID,CODE,SIGNDATE FROM table1 WHERE SIGNDATE >= TO_DATE(‘2017-04-01 00:00:00‘,‘yyyy-MM-dd HH24:mi:ss‘)
AND SIGNDATE <= TO_DATE(‘2017-04-30 23:59:59‘,‘yyyy-MM-dd HH24:mi:ss‘) AND DELETED=0 AND ISPRINT=1
UNION ALL
select ID,CODE,SIGNDATE FROM table2 WHERE SIGNDATE >= TO_DATE(‘2017-04-01 00:00:00‘,‘yyyy-MM-dd HH24:mi:ss‘)
AND SIGNDATE <= TO_DATE(‘2017-04-30 23:59:59‘,‘yyyy-MM-dd HH24:mi:ss‘) AND DELETED=0 AND ISPRINT=1
UNION ALL
select ID,CODE,SIGNDATE FROM table3 WHERE SIGNDATE >= TO_DATE(‘2017-04-01 00:00:00‘,‘yyyy-MM-dd HH24:mi:ss‘)
AND SIGNDATE <= TO_DATE(‘2017-04-30 23:59:59‘,‘yyyy-MM-dd HH24:mi:ss‘) AND DELETED=0 AND ISPRINT=1
UNION ALL
select ID,CODE,SIGNDATE FROM table4 WHERE SIGNDATE >= TO_DATE(‘2017-04-01 00:00:00‘,‘yyyy-MM-dd HH24:mi:ss‘)
AND SIGNDATE <= TO_DATE(‘2017-04-30 23:59:59‘,‘yyyy-MM-dd HH24:mi:ss‘) AND DELETED=0 AND ISPRINT=1 )
WHERE SIGNDATE >= TO_DATE(‘2017-04-01 00:00:00‘,‘yyyy-MM-dd HH24:mi:ss‘)
) group by to_char(SIGNDATE,‘yyyy-MM-dd HH24:mi‘)
order by to_char(SIGNDATE,‘yyyy-MM-dd HH24:mi‘);
Oracle下按分钟多表查询