Window Functions Query Builder

Build advanced SQL queries using window functions

6/11/2026
Prompt
Build a query using window functions for this requirement:

**Tables:**
```sql
{{TABLE_SCHEMA}}
```

**Requirement:** {{REQUIREMENT}}

Examples:
- Running totals
- Rankings
- Moving averages
- Lead/lag comparisons
- Percentile calculations
- Row numbering with partitions

**Database System:** {{DATABASE_SYSTEM}}

Please provide:
1. The complete query with window functions
2. Explanation of each window function used
3. PARTITION BY and ORDER BY rationale
4. Frame specification explanation (ROWS/RANGE)
5. Alternative approaches without window functions
6. Performance comparison
7. Sample output with explanation

Or press ⌘C to copy

Variables (3)

Replace these placeholders with your own content before using the prompt.

[{TABLE_SCHEMA][{REQUIREMENT][{DATABASE_SYSTEM]

Ready to use?

Copy and paste into your favorite AI tool

Test this prompt live

Try it in our AI Playground with Claude

Open Playground

Explore more Coding prompts

Browse Coding

Command Palette

Search for a command to run...