1
我有被发送daily
领域,Postgres的查询 - 找到开始和周结束之差,每周
total_user_count, sent_at
列user_report
。
我试图找到total new users per week
,其被定义为
difference in user count from the beginning of the week to the ending of the week.
我似乎遇到了问题,虽然制定此查询,我有什么是
SELECT DATE_TRUNC('day', sent_at AT TIME ZONE '+08') as date, total_user_count
FROM user_state_report
WHERE timestamptz_cmp(DATE_TRUNC('week', sent_at AT TIME ZONE '+08') , DATE_TRUNC('day', sent_at AT TIME ZONE '+08'))=0
ORDER BY TIMESTAMP
哪给我每周的总用户数。但我想每周新注册,而不是总数量
理想输出:
Date [monday of the week X], users registered in this week 14-08-2017 300 21-08-2017 400
谢谢! :)
非常感谢! :)像一个魅力工作 – Wboy
我的荣幸。祝你有美好的一天 –