Skip to content Skip to sidebar Skip to footer

Sqllite Strftime Function To Get Grouped Data By Months

i have table with following structure and data: I would like to get grouped data by months in given date range for example (from 2014-01-01 to 2014-12-31). Data for some months ca

Solution 1:

SELECT Month,
       (SELECT COUNT(*)
        FROM MyTable
        WHERE date LIKE Month || '%'
       ) AS Dials_Cnt,
       (SELECT SUM(Call_Result = 'APPT')
        FROM MyTable
        WHERE date LIKE Month || '%'
       ) AS Appt_Cnt,
       ...
FROM (SELECT '2014-01' AS Month UNION ALL
      SELECT '2014-02'          UNION ALL
      SELECT '2014-03'          UNION ALL
      ...
      SELECT '2014-12')

Post a Comment for "Sqllite Strftime Function To Get Grouped Data By Months"