Skip to content

Instantly share code, notes, and snippets.

@pt2121
Created April 21, 2019 14:26
Show Gist options
  • Save pt2121/1323b6f47994e034a6c224d89341281f to your computer and use it in GitHub Desktop.
Save pt2121/1323b6f47994e034a6c224d89341281f to your computer and use it in GitHub Desktop.
SELECT device_model, COUNT(user_id) AS USERS
FROM app.data
WHERE user_id IN (SELECT user_id FROM app.data WHERE created_at BETWEEN TO_TIMESTAMP('01-01-2018', 'dd-mm-yyyy') AND TO_TIMESTAMP('01-07-2018', 'dd-mm-yyyy'))
AND user_id NOT IN (SELECT user_id FROM app.data WHERE created_at > TO_TIMESTAMP('01-07-2018', 'dd-mm-yyyy'))
GROUP BY device_model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment