按日期按组获取活动历史记录

时间:2014-10-12 06:46:55

标签: postgresql

reminder_user table
====================
ruid    uid from_date   to_date    instructions created_timestamp
1        1  1413072000  1413072000  sample      1413072000
2        1  1413072000  1413072000  sample      1413072000
3        2  1413072000  1413072000  sample      1413072000
4        2  1413072000  1413072000  sample      1413072000
5        2  1413072000  1413072000  sample      1413072000
6        3  1413072000  1413072000  sample      1413072000

reminder_setting table
=======================                 
rsid    ruid    time          postpond_status   time        postpond_time
1        1      1413072000     postpond         1413072000  1413072000
2        1      1413072000     postpond         1413072000  1413072000
3        2      1413072000     postpond         1413072000  1413072000
4        2      1413072000     postpond         1413072000  1413072000


reminder_activity table
========================        
raid    rsid    created_timestamp   status
1         1          1413072000      missed
2         2          1413072000      missed

以上3个表的目的是

  1. reminder_user表 - 针对特定用户存储提醒设置
  2. reminder_setting表 - 存储每个推迟活动的历史记录
  3. reminder_activity表 - 根据特定提醒设置存储每项活动
  4. 我正在努力获取postgres查询到过去30天的记录历史记录,这些记录按照提醒_活动表中的created_timestamp列中的日期和限制分组。任何帮助都非常感谢。

    Result set expected as below
    ==============================
    
    Date           Time     instruction
    10/12/2014     12:00    sample
                   13:00    sample
    10/11/2014     10:00    sample
                   12:00    sample
                   13:00    sample
    
    Date from created_timestamp Column from reminder_activity table
    Time from time Column from reminder_setting table
    instructions from instructions column of reminder_user table
    

0 个答案:

没有答案