acquisitions_with_av_gbp AS()

in super-mode-calculator/src/lib/build-query.ts [94:108]


acquisitions_with_av_gbp AS (
	SELECT acq.*,
		CASE payment_frequency
			WHEN 'ONE_OFF' THEN amount * exch.to_gbp_rate
			WHEN 'MONTHLY' THEN (amount * exch.to_gbp_rate)*12
			WHEN 'ANNUALLY' THEN amount * exch.to_gbp_rate
			END AS av_gbp, exch.from_currency
		FROM acquisitions AS acq JOIN exchange_rates AS exch ON acq.currency = exch.from_currency),
acquisitions_agg AS (
	SELECT region, referrer_url, SUM(av_gbp) sum_av_gbp, COUNT(*) acquisitions
	FROM acquisitions_with_av_gbp
	GROUP BY 1, 2
	),
views_with_regions AS (
		SELECT *,  ${regionSql('country_key')}