时间:2021-07-01 10:21:17 帮助过:13人阅读
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下按分钟多表查询
标签:nio group 多表 bsp delete acl order by to_char to_date