SQL language reference
Last updated Oct 2, 2026 The SQL API supports a read-only subset of SQL for analytics queries. SQL keywords and function names are case-insensitive. Dataset and field names are case-sensitive.
Every query must read one schema-qualified dataset and must include an account or zone scope and a lower time bound. For HTTP API requests, you can provide scope and time bounds in SQL or through the JSON request fields. Workers binding queries are the exception: the binding supplies account scope automatically, so include only the time bound in SQL. For example:
SELECT
clientRequestHttpHost AS host,
COUNT(*) AS requests
FROM events.httpRequests
WHERE accountTag = '<ACCOUNT_TAG>'
AND timestamp >= NOW() - INTERVAL '1' HOUR
GROUP BY clientRequestHttpHost
ORDER BY requests DESC
LIMIT 10
Reference
Unsupported features
The SQL API does not support arbitrary ClickHouse SQL. Unsupported features include:
- Data modification or definition statements, including
INSERT,UPDATE,DELETE,CREATE,ALTER, andDROP. - Joins, unions, common table expressions, and general subqueries. One restricted derived-table projection is supported.
- Window functions.
- Row-level
SELECT DISTINCT.COUNT,SUM, andAVGsupportDISTINCTon unsampled datasets and Workers Analytics Engine datasets. FETCH. ClickHouse-backed datasets supportOFFSETwithLIMIT.EXPLAIN,ANALYZE,DESCRIBE,VALUES, andUNNEST.SIMILAR TO,LIKE ... ESCAPE, and user-authored casts.- Aggregate
FILTERand aggregate-localORDER BYclauses.
The API returns an HTTP 422 response when a statement contains unsupported syntax.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/analytics/sql-api/sql-reference/#page","headline":"SQL language reference","description":"Reference for the SQL syntax supported by the SQL API.","url":"https://developers.cloudflare.com/analytics/sql-api/sql-reference/","inLanguage":"en","image":"https://developers.cloudflare.com/analytics/sql-api/sql-reference/og.png?v=8e7234eb8b0d8a77","dateModified":"2026-10-02","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Data types, literals, arrays, and JSON values supported by the SQL API. title: Data types and literals image: https://developers.cloudflare.com/analytics/sql-api/sql-reference/data-types/og.png?v=e0a6da4814b37cd9
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/analytics/llms.txt
Use this file to discover all available pages before exploring further.
Docs