Alaricy

Расш. возм. SQL. Урок 7. Подзапросы. задача 4/4

Jan 13th, 2022 (edited)
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.32 KB | None | 0 0
  1. SELECT
  2.     EXTRACT (week FROM subq.trunc_date) AS week_number,
  3.     AVG(subq.transaction_per_day) AS avg_week_transaction
  4. FROM   
  5.     (SELECT  
  6.         COUNT(DISTINCT id_transaction) AS transaction_per_day,
  7.         DATE_TRUNC('day', DATE) AS trunc_date
  8.     FROM
  9.         transactions
  10.     GROUP BY
  11.         trunc_date) AS subq;
  12. GROUP BY
  13.    week_number
Add Comment
Please, Sign In to add comment