PostgreSQL - aggregating data by date from datetime field -
i have data on time particular users , timestamp of form 2013-11-23 16:00:00-05 - there's minute minute date each user , corresponding usage value.
so table has values: user_id, localminute, usage.
i trying aggregate usage @ day wise level, did far below s looking easier way without creating dummy column date_event:
alter table tablename add column date_event date update table set date_event = date(localminute) select sum(use), date_event tablename group date_event
my question how can extract date timestamp , aggregate in single query. help!
just cast date:
select sum(use), localminute::date tablename group localminute::date;
or using standard sql:
select sum(use), cast(localminute date) tablename group cast(localminute date);
Comments
Post a Comment