Write complex SQL step-by-step in natural language — then compile it into auditable, production-ready SQL.
AI-assisted. Compiler-guaranteed. No black boxes.
MIT License for examples • SQLazy application is proprietary
Writing analytical SQL is hard.
Reviewing AI-generated SQL is even harder.
Modern AI can produce SQL that runs — but you never know whether you can trust it.
When queries become deeply nested with window functions and subqueries, they become:
- hard to review
- hard to debug
- hard to maintain
- hard to port across databases
SQLazy turns SQL development into a step-by-step workflow you can actually understand and audit.
Instead of generating one giant SQL statement, SQLazy lets you:
- Describe each step in semi-natural language
- Verify the logic step-by-step
- Compile the steps into native SQL
The final SQL is generated by a compiler, not an LLM.
That means:
- No AI hallucinations in the final SQL
- Fully auditable logic
- Production-ready output
AI helps you write the steps, not the final SQL.
You review the logic first.
Then the compiler gives you the trustworthy the SQL.
Result: AI productivity + compiler reliability.
Even the most complex analytics queries become simple building blocks:
- calculate
- filter
- summarize
- group
- join
- rank
- segment
...
No more nested SQL nightmares.
Debugging complex SQL is painful.
You usually can't inspect intermediate results.
SQLazy provides step-by-step execution so you can see:
- intermediate tables
- intermediate calculations
- intermediate filters
Exactly like debugging code.
Write your logic once.
Generate SQL for multiple databases.
No more rewriting queries for different SQL dialects.
LLMs help you:
- rewrite messy natural language into SQLazy steps
- decompose complex requirements into workflows
But you stay in control of the logic.
Instead of writing one large SQL statement, the logic is expressed as a step-by-step workflow.
Each step represents a single transformation.
| Variable | Anchor | Statement |
|---|---|---|
| t1 | stock | filter CODE = 100046 |
| t2 | sort DT asc | |
| t3 | segment CL down as NoRisingDays | |
| t4 | summarize DT count as ContinuousDays group NoRisingDays | |
| summarize ContinuousDays max as max_ContinuousDays |
This workflow is easy to read and easy to review.
Each step does only one simple thing.
WITH t2 AS (
SELECT
CODE,
DT,
CL
FROM
stock
WHERE
CODE = 100046
)
SELECT
MAX(ContinuousDays) AS max_ContinuousDays
FROM
(
SELECT
NoRisingDays,
COUNT(DT) AS ContinuousDays
FROM
(
SELECT
CODE,
DT,
CL,
SUM(
CASE
WHEN CL < col__3 THEN 1
ELSE 0
END
) OVER (
ORDER BY
DT ASC
) + 1 AS NoRisingDays
FROM
(
SELECT
t2. *,
LAG(CL) OVER (
ORDER BY
DT ASC
) AS col__3
FROM
t2
) sub__4
) t3
GROUP BY
NoRisingDays
) t4This SQL is:
- deeply nested
- hard to review
- hard to debug
- hard to modify
But the SQLazy workflow is easy to read, review, and audit.
🌐 Try the Web App: https://sqlazy.com
- online playground
- free usage (limited compute)
- perfect for quick experiments & sharing
Best for daily work and large datasets.
Features:
- unlimited local debugging
- bring your own LLM key
- customizable prompts
- full performance
| Feature | Web App (sqlazy.com) | Desktop IDE |
|---|---|---|
| Natural language → SQL | ✅ Full SQL generation capabilities | ✅ Full SQL generation + native SPL generation |
| AI assistance & planning | ✅ Usage-limited (hosted LLM) | ✅ Bring your own LLM key, no usage limits, customizable prompts |
| Step-by-step debugging | ✅ Limited dataset size | ✅ Powered by esProc engine, supports large datasets |
| Data stays in your environment | ❌ Runs in the cloud | ✅ Supports private/on-prem deployment (commercial license) |
| Interface & language support | English UI and terminology | Full English + Chinese UI and terminology |
| Database dialect support | Same core compiler | Same core compiler |
| Availability | Free | Free for personal & team online use; commercial license for private/on-prem deployment |
| Version control | Always up-to-date in the cloud | Free edition auto-updates; commercial edition supports version locking |
We collected real SQL problems from the Internet and solved them step-by-step with SQLazy. These examples show how complex analytical queries can be expressed as clear, auditable workflows.
Explore the examples by real analytics scenarios:
Detect continuous patterns in time-series data – one of the hardest problems to solve with standard SQL.
- Find the longest consecutive rising streak for a single stock
- Get the exact start and end dates of the longest rising period
- Filter all stocks with rising streaks longer than N days
- Extract every rising streak period that exceeds 3 days
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/consecutive-trends
Split event streams into logical sessions and generate sequence numbers based on time gaps or state changes.
- Number events and reset counters when time gaps exceed 1 hour
- Create conditional running totals that reset when a condition is met
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/event-sequencing
Dynamic grouping based on data values and running status – eliminates complex SUM(CASE WHEN ...) OVER (...) patterns.
- Calculate totals differently for single-customer vs multi-customer groups
- Group records automatically when a running status flag changes
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/conditional-grouping
Rolling window calculations and interval aggregations with automatic missing value backfilling.
- Build minute-by-minute price bars (OHLC) with gap filling
- Calculate 5-minute rolling totals over time-series data
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/time-window-analytics
Prepare messy datasets for reporting and analytics with simple, readable steps.
- Hide repeated values in reports (replace duplicates with NULL)
- Generate status flags based on recent consecutive row values
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/data-cleaning
Add, modify or inject rows into grouped results without complex union operations.
- Insert a header row before each group of records
- Split total amounts across multiple rows while preserving the grand total
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/group-enhancement
Reshape data for BI tools and reports – no more dynamic SQL or stored procedures.
- Turn unique row values into dynamic columns (automatic pivot tables)
- Split invoice totals evenly across line items while maintaining sum integrity
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/dynamic-reporting
Real-world trading and finance SQL problems that analysts deal with daily.
- Calculate the longest consecutive rising streak for any stock
- Identify all stocks that have risen for more than 3 consecutive days
- Generate OHLC price bars from raw tick data
- Extract all rising streak periods for market analysis
- Compute rolling averages and totals for technical indicators
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/financial-analysis
Sessionization and event tracking patterns for user behavior analysis.
- Split user activity into sessions based on inactivity timeouts
- Add summary header rows before each user's event group
- Backfill missing time intervals in user activity data
- Track session-based counters that reset on new sessions
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/behavioral-analytics
Complex summarization patterns that require stateful calculations across rows.
- Dynamic conditional grouping with custom aggregation logic
- Stateful running totals with reset triggers
- Calculations that depend on values from previous consecutive rows
- Nested ordered aggregation within hierarchical groups
👉 https://github.com/SPLWare/sqlazy/tree/master/examples/advanced-aggregation
- Step-by-step natural language → SQL
- Step debugging
- Cross-database SQL generation
- MySQL / PostgreSQL / Oracle support
- Snowflake / BigQuery support
- Recursive queries
- Fully automatic workflow generation from plain English
- Very old database versions (e.g. MySQL 5.5)
This repository contains documentation and example workflows only.
The SQLazy application (Web App and Desktop IDE) is proprietary software and is not included in this repository.
All files inside the /examples directory are released under the MIT License.
See the LICENSE file for details.
- Issues: https://github.com/SPLWare/sqlazy/issues
- Forum: https://c.esproc.com/
- Enterprise licensing: contact@scudata.com
SQLazy is built on top of the esProc SPL engine:
https://github.com/SPLWare/esProc