SQLlite strftime function to get grouped data by months

前端 未结 1 795
你的背包
你的背包 2020-12-22 13:25

i have table with following structure and data:

\"enter

I would like to get gr

相关标签:
1条回答
  • 2020-12-22 13:31
    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')
    
    0 讨论(0)
提交回复
热议问题