总和查询

时间:2019-03-04 22:44:58

标签: sum union union-all

我在下面查询UNION ALL。我只需要修改它,这样它将求和结果。

select count (*)
from BAU_DEAN_USER 
where checked_date >= date '2019-03-01' and checked_date < date '2019-03-05'

UNION ALL

select count (*)
from BAU_DEAN_USER_ARCHIVE 
where checked_date >= date '2019-03-01' and
      checked_date < date '2019-03-05'

1 个答案:

答案 0 :(得分:0)

select count (*) from 
(select 'a' from
BAU_DEAN_USER where checked_date >= date '2019-03-01' and checked_date < date '2019-03-05'

UNION ALL

select 'a' from BAU_DEAN_USER_ARCHIVE where checked_date >= date '2019-03-01' and checked_date < date '2019-03-05')