У меня есть PostGreSQL заявление, которое:Как Объединить Same PostgreSQL Data
(select cast(start_time as date) as time , SUM(count) as count
from tbl_product
where (cast(start_time as date) >= '2016-08-30 23:00:00' and cast(start_time as date) <= '2016-09-01 20:00:00')
and (extract(hour from start_time) >= 23 and extract(hour from start_time) <= 24)
group by time order by time limit 5)
UNION (select cast(start_time as date) as time , SUM(count) as count
from tbl_product
where (cast(start_time as date) >= '2016-08-31 23:00:00' and cast(start_time as date) <= '2016-09-01 20:00:00')
and (extract(hour from start_time) >= 0 and extract(hour from start_time) < 20)
group by time order by time limit 5)
Но он возвращает те же данные для той же даты, из-за UNION
заявления
time count
date numeric
"2016-08-31" 543595
"2016-08-31" 3666277
"2016-09-01" 3365093
Как я могу добавьте эти значения данных, например:
time count
date numeric
"2016-08-31" 4209872
"2016-09-01" 3365093
Спасибо за помощь.
Он отлично работает, спасибо –