aggregate - MySQL - make a weekly report that includes starting day (twist: week starting wednesday) -
i have kind of table time based data:
| entity_id | ttime | value | ------------------------------------------- | 1 | 2014-11-01 00:00:04 | 553 | | 1 | ... | 600 | | 2 | ... | 234 |
i want average of value grouped week , entity_id. starting day of week appear in results. additional complexity week starts on wednesday.
i can group year(ttime + interval 3 day), week(ttime + interval 3 day) possible print first day of group (wednesday) in results?
thanks
maybe this:
select `entity_id`, date_sub(ttime, interval weekday(ttime)-2 day), sum(`value`) `table` group `entity_id`, yearweek(ttime + interval 4 day)
Comments
Post a Comment