Table inputs: enter image description here enter image description here
Help me figure out what's wrong.
Tried this
Select ifnull(count(distinct t.client_id), 0) as Cancelled, t.request_at as Day
from Trips t
left join Users u on t.client_id = u.users_id or t.driver_id = u.users_id
where t.status != "completed" and u.banned = "No"
group by Day
and expected output is:
Cancelled | Day |
---|---|
2 | 2013-10-01 |
1 | 2013-10-03 |
0 | 2013-10-02 |
and my output is:
Cancelled | Day |
---|---|
2 | 2013-10-01 |
1 | 2013-10-03 |