client_id <- (2260419,2260412,2260413,2260415)
transaction_date <- (2016-09-03, 2016-09-04, 2016-09-06, 2016-09-07)
amount <- (350.0, 250.0,431.0,220.0)
month_ARPU AS
(SELECT
visit_month,
Avg(revenue) AS ARPU
FROM
(SELECT
Cust_id,
Datediff(MONTH, ‘2010-01-01’, transaction_date) AS visit_month,
Sum(transaction_size) AS revenue
FROM transactions
WHERE transaction_date > Dateadd(‘year’, -1, CURRENT_DATE)
GROUP BY
1,
2)
GROUP BY 1)
I understand how SELECT, GROUP BY, COUNT(1), SUM()
and AS() works individually but not as a whole like in the code above, mainly how COUNT(1)
and SUM()
are working.