I have following query which should return result like this:
SELECT strftime('%w', dc.date) as day,
strftime('%H', dc.date) AS BEST_HOUR,
COUNT(*) AS DIALS_CNT,
SUM(CASE WHEN dc.call_result = 'APPT' THEN 1 ELSE 0 END) AS 'APPT_CNT',
SUM(CASE WHEN dc.call_result = 'CONV_NO_APPT' THEN 1 ELSE 0 END) AS 'CONVERS_CNT' ,
SUM(CASE WHEN dc.call_result = 'CANNOT_REACH' THEN 1 ELSE 0 END) AS 'CANNOT_REACH_CNT'
FROM dialed_calls dc
GROUP BY strftime('%w', dc.date)
ORDER BY strftime('%w', dc.date) ASC
;
Problem is that if i'm running this query on device. I got seult like this:
-------------------------------------------------------------------
DAY | BEST_HOUR | DIALS_CNT | APPT_CNT | CONVERS_CNT | CANNOT_REACH_CNT
-------------------------------------------------------------------
1 | 13 | 20 | 10 | 5 |
-------------------------------------------------------------------
2 | 8 | 30 | 15 | 7 | 13
-------------------------------------------------------------------
3 | 8 | 30 | 15 | 7 | 13
-------------------------------------------------------------------
5 | 0 | 0 | 0 | 0 | 0
-------------------------------------------------------------------
So there are some days in week missing.
I would like to ask, how can i update query to get results for all days in week (mo-su) with null values in no data is existing for given day in week. Ordered by ASC and starting from monday and ending in sunday.
Many thanks for any advice.
Aucun commentaire:
Enregistrer un commentaire