How to group and count by two different dates? I have two different columns:

created_at          | updated_at
--------------------| -------------------
2017-03-12 14:47:20 | 2017-03-10 14:47:20
2017-03-11 12:47:20 | 2017-03-10 14:47:20
2017-03-11 10:47:20 | 2017-03-10 14:47:20


I want to group records by date as follows:

event_date | created_at | updated_at
------------------------------------
2017-03-10 |    0       |   3
2017-03-11 |    2       |   0
2017-03-12 |    1       |   0
The domain for "Date" (Date is a reserved word, let's call it event_date) is a union between created_at and updated_at.

select created_at as event_time, 'C' as event_type
from T
union all -- the legs are disjoint
select updated_at as event_time, 'U' as event_type
from T


From there we can extract the date and count each type:

select date(event_time) as event_date
     , count(case when event_type = 'C' then 1 end) as created_at
     , count(case when event_type = 'U' then 1 end) as updated_at
from (
    select created_at as event_time, 'C' as event_type
    from T
    union all -- the legs are disjoint
    select updated_at as event_time, 'U' as event_type
    from T
) as TT
group by date(event_time)
order by date(event_time);


Untested, but the principle should be valid.