Created
February 8, 2019 14:24
-
-
Save graingerkid/bf42f48a3b777d367aaf829930a3464e to your computer and use it in GitHub Desktop.
SLQ statement to select only the max values for the given date range - basically which landing pages have had their best ever month *this* month. Change MAX() to MIN() to get the biggest losers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
t.landing_page, t.all_impressions | |
FROM | |
landing_pages_client_v3 AS t | |
JOIN | |
( | |
SELECT | |
landing_page, | |
MAX(all_impressions) AS max_all_impressions | |
FROM landing_pages_client_v3 | |
GROUP BY landing_page | |
) AS dt | |
ON dt.landing_page = t.landing_page AND | |
dt.max_all_impressions = t.all_impressions | |
WHERE profile_id=565 and | |
t.dates >= '2019-01-01 00:00:00' AND | |
t.dates < '2019-31-01 00:00:00' limit 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment