SQL editor

PostHog's SQL editor allows you to run ad-hoc queries directly against your data warehouse using PostHog SQL - a SQL dialect optimized for analytics. Analyze and model your product data alongside data from any source, all within PostHog.

PostHog SQL editor screenshot

Features

Feature
Description
Direct data access
Query all your data in PostHog, including PostHog-specific tables (events, persons) and synced warehouse sources
✅
HogQL support
Uses PostHog's SQL variant with simplified property access (dot notation like properties.$current_url), null handling, and ClickHouse functions
✅
Autocomplete
Intelligent code completion for tables, columns, and SQL keywords to speed up query writing
✅
Schema browser
View and search the schema of all available sources, PostHog tables, and saved views directly in the editor
✅
Save as views
Save queries as views accessible from the data warehouse tab, visible to all project users
✅
Draft queries
Save draft queries for later without cluttering the saved views list
Coming soon
DuckDB syntax support
Full support for DuckDB SQL syntax and functions when connected to a managed DuckDB warehouse
Coming soon
Add queries to notebooks
Use PostHog notebooks to collect warehouse info, research topics, or just as a scratch pad
✅
Write SQL without knowing SQL
Let PostHog AI write SQL for you
✅
Simplified syntax
Access properties with dot notation like properties.$browser
✅
Smart joins
Automatic joins between events, persons, and groups
✅
Product functions
Built-in functions for cohorts, feature flags, and more
✅
Time zone handling
Automatic time zone conversion for your project
✅

Read the SQL editor docs →