Created
August 31, 2022 14:39
-
-
Save Zmey56/117128a4dc3a96efa18fed09d1a22d07 to your computer and use it in GitHub Desktop.
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
data_new_users_q = """ | |
select date, | |
uniqExact(user_id) as new_user, | |
uniqExactIf(user_id, source='ads') as new_user_ads, | |
uniqExactIf(user_id, source='organic') as new_user_organic | |
from( | |
select user_id, | |
source, | |
min(dt_reg) as date | |
from | |
(select user_id, | |
min(toDate(time)) as dt_reg, | |
source | |
from simulator_20220620.feed_actions | |
where toDate(time) between today() - 8 and today() - 1 | |
group by user_id, source | |
union all | |
select user_id, | |
min(toDate(time)) as dt_reg, | |
source | |
from simulator_20220620.message_actions | |
where toDate(time) between today() - 8 and today() - 1 | |
group by user_id, source) as t1 | |
group by user_id, source) as t2 | |
group by date | |
where date between today() - 8 and today() - 1 | |
""" | |
data_new_users = pd.DataFrame(ph.read_clickhouse(query=data_new_users_q, connection=connection)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment