On Github aeud / data-pres
SELECT
timestamp(utc_usec_to_month(createdAt)) month,
round(sum(totals.validNetRevenue)) net_revenue,
sum(totals.validOrders) orders,
FROM dwh.orders
WHERE createdAt >= utc_usec_to_year(current_date())
GROUP BY 1
ORDER BY 1 DESC
SELECT
device.browser browser,
sum(totals.visits) sessions,
sum(totals.pageviews) pageviews,
FROM (
table_date_range(
[luxola.com:luxola-analytics:50639087.ga_sessions_],
timestamp(date_add(utc_usec_to_week(current_date(), 0), -1, 'week')),
timestamp(utc_usec_to_week(current_date(), 0))
)
)
GROUP BY 1
ORDER BY 2 DESC
SELECT
timestamp(date_start) date,
sum(integer(impressions)) impressions,
sum(clicks) clicks,
round(sum(clicks) / sum(integer(impressions)), 4) ctr,
FROM [luxola.com:luxola-analytics:facebook.insights]
WHERE timestamp(date_start) >= date_add(current_date(), -1, 'week')
GROUP BY 1
ORDER BY 1 DESC
-- [TEST Daily net revenue
SELECT
timestamp(date(o.createdAt)) date,
o.address.country country,
round(sum(o.totals.netRevenue)) net
FROM
[dwh.orders] o
WHERE
o.isValid
and date(o.createdAt) >= DATE(STRFTIME_UTC_USEC(date_add(current_date(), -1, 'DAY'), '%Y-%m-01'))
and date(o.createdAt) < current_date()
GROUP BY
date, country
ORDER BY
date, country