具有用户标识的sql组和具有一天间隔的created_at时间

时间:2014-09-26 09:36:54

标签: postgresql

    id  | search_id | user_id |   data   | action | activitable_id | activitable_type |         created_at         |         updated_at         
    -----+-----------+---------+----------+--------+----------------+------------------+----------------------------+----------------------------
     213 |         1 |       2 | ---     +| 1      |          69801 | Mention          | 2014-09-25 23:28:55.592874 | 2014-09-25 23:28:55.592874
         |           |         | taglist:+|        |                |                  |                            | 
         |           |         | - - 54  +|        |                |                  |                            |  
         |           |         |          |        |                |                  |                            | 
     212 |         1 |       2 | ---     +| 1      |          69803 | Mention          | 2014-09-25 23:28:49.173146 | 2014-09-25 23:28:49.173146
         |           |         | taglist:+|        |                |                  |                            | 
         |           |         | - - 73  +|        |                |                  |                            | 

     211 |         1 |       2 | ---     +| 1      |          69802 | Mention          | 2014-09-25 23:28:45.132325 | 2014-09-25 23:28:45.132325
         |           |         | taglist:+|        |                |                  |                            | 
         |           |         | - - 73  +|        |                |                  |                            | 

     210 |         1 |       1 | ---     +| 1      |          69801 | Mention          | 2014-09-25 21:43:43.61208  | 2014-09-25 21:43:43.61208
         |           |         | taglist:+|        |                |                  |                            | 
         |           |         | - - 73  +|        |                |                  |                            | 

     209 |         1 |       1 | ---     +| 1      |          69833 | Mention          | 2014-09-23 12:51:47.973599 | 2014-09-23 12:51:47.973599
         |           |         | taglist:+|        |                |                  |                            | 
         |           |         | - - 54  +|        |                |                  |                            | 
     208 |         1 |       1 | ---     +| 1      |          69836 | Mention          | 2014-09-23 12:51:41.396198 | 2014-09-23 12:51:41.396198
         |           |         | taglist:+|        |                |                  |                            | 
         |           |         | - - 54  +|        |                |                  |                            | 
         |           |         |          |        |                |                  |                            | 
     207 |         1 |       1 | ---     +| 1      |          69832 | Mention          | 2014-09-23 12:51:36.552109 | 2014-09-23 12:51:36.552109
         |           |         | taglist:+|        |                |                  |                            | 
         |           |         | - - 66  +|        |                |                  |                                     
    (7 rows)

我有这些user_activity表。我想用user_id和created_at日期对它进行分组,间隔为一天。我可以使用user_id和created_at对其进行分组(但没有一天的间隔)

0 个答案:

没有答案