HogQL queries for PostHog
SkillDatabases & dataHelps your agent write correct HogQL queries to analyze PostHog product analytics data.
Use HogQL queries for PostHog in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add HogQL queries for PostHog and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the HogQL queries for PostHog skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
About this skill
HogQL queries for PostHog analytics
What this skill tells your AI
The instructions your AI receives, as published by posthog/skills in skills/posthog/tools-and-features/skills/hogql/SKILL.md and read by Ahel’s review.
This skill helps you write HogQL queries for PostHog analytics. HogQL is PostHog's SQL dialect, a wrapper around ClickHouse SQL with simplified property access and PostHog-specific functions.
Reference files
references/expressions.md- Sql expressions - docsreferences/aggregations.md- Supported aggregations - docsreferences/clickhouse-functions.md- Supported clickhouse functions - docsreferences/data-access.md- Accessing data using sql - docsreferences/variables.md- Sql variables - docsreferences/useful-functions.md- Useful sql functions - docsreferences/posthog.md- PostHog table schemas (events, persons, groups, sessions)references/sessions.md- Sessions - docs
Consult the documentation for SQL syntax, available functions, and query patterns.
Key principles
- Property access: Use
properties.$property_namefor event properties andperson.properties.$property_namefor person properties - Null handling: HogQL has simplified null handling compared to raw ClickHouse SQL
- Filters placeholder: Use
{filters}in queries to allow UI-based filtering in PostHog dashboards - Aggregations: Prefer ClickHouse aggregation functions like
count(),uniq(),avg(),sum()
Common patterns
Event queries
SELECT event, count()
FROM events
WHERE {filters}
GROUP BY event
ORDER BY count() DESC
Property breakdowns
SELECT properties.$browser AS browser, count()
FROM events
WHERE event = '$pageview' AND {filters}
GROUP BY browser
Person properties
SELECT person.properties.email, count()
FROM events
WHERE {filters}
GROUP BY person.properties.email
Framework guidelines
- Use properties.$name syntax for event properties, person.properties.$name for person properties
- Use bracket notation for special characters like properties['$feature/cool-flag']
- For cohorts, filter with person_id IN COHORT 'cohort-name'
- For actions, use matchesAction('action-name') in WHERE clauses
- Include {filters} placeholder in WHERE clauses to enable UI-based filtering in dashboards
- Use {variables.name} for reusable SQL variables across dashboards
- Access dashboard date range with {filters.dateRange.from} and {filters.dateRange.to}
- ALWAYS include a time range filter - shorter is faster (e.g., timestamp >= now() - INTERVAL 7 DAY)
- Prefer uniq() over count(distinct) for counting unique values - it's more efficient
- Don't scan the same table multiple times - use materialized views for reusable subsets
- Use timestamp-based pagination instead of OFFSET for large datasets
- Name queries descriptively for easier debugging in query_log
- Use dateTrunc() for time-based grouping (e.g., dateTrunc('day', timestamp))
- For funnel queries, use windowFunnel() or sequenceMatch() functions
- Test queries in the PostHog SQL editor before using them in insights or the API
Signals
- GitHub stars
- 72
- Forks
- 7
- Last commit
- Oct 2026
Others that do the same job
Advanced
- Item type
- skill
- Key
tools-and-features-hogql- Source
- github.com/posthog/skills
Related picks
Skill · clickhouse
The pick for ClickHouseclickhouse-observability
Skill · jeremylongshore
The pick for ClickHousegenerating-clickhouse-query-performance-reports
Skill · posthog
The pick for ClickHouseanalytics
Skill · coreyhaines31
More in Databases & datasupabase
Skill · supabase
More in Databases & dataconnect
Skill · composiohq
More in Databases & data