0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-29 03:04:16 +01:00
posthog/ee/clickhouse/sql/element.py
2020-11-11 15:08:12 +01:00

33 lines
641 B
Python

GET_ELEMENTS = """
SELECT
elements_chain, count(1) as count
FROM events
WHERE
team_id = %(team_id)s AND
event = '$autocapture' AND
elements_chain != ''
{date_from}
{date_to}
{query}
GROUP BY elements_chain
ORDER BY count DESC
LIMIT 100;
"""
GET_VALUES = """
SELECT
extract(elements_chain, %(regex)s) as value, count(1) as count
FROM (
SELECT elements_chain
FROM events
WHERE team_id = %(team_id)s
AND event = '$autocapture'
AND elements_chain != ''
AND match(elements_chain, %(filter_regex)s)
LIMIT 100000
)
GROUP BY value
ORDER BY count desc
LIMIT 100;
"""