Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- EXTRACT (week FROM subq.trunc_date) AS week_number,
- AVG(subq.transaction_per_day) AS avg_week_transaction
- FROM
- (SELECT
- COUNT(DISTINCT id_transaction) AS transaction_per_day,
- DATE_TRUNC('day', DATE) AS trunc_date
- FROM
- transactions
- GROUP BY
- trunc_date) AS subq;
- GROUP BY
- week_number
Add Comment
Please, Sign In to add comment