---
name: sql-window-functions-helper
description: "Design SQL queries using advanced window functions for analytic tasks. Use when the user wants help with SQL Window Functions Helper. Related topics: coding, database, sql."
---

# SQL Window Functions Helper

Design SQL queries using advanced window functions for analytic tasks.

## How to use this skill

1. Ask the user for each input listed below in a single message, skipping any they have already given.
2. Where options are listed, offer them, but accept other answers too.
3. Fill the answers into the prompt template, then follow the completed prompt to produce the result.

## Inputs

- **Table Name** (free text, e.g. "")
- **Target Operation** (choose one: Running total, Rank/Denserank, Lead/Lag comparison, Moving average)
- **Partition Field** (free text, e.g. "")
- **Order Field** (free text, e.g. "")

## Prompt template

## Introduction
Generate SQL queries using partition, lag, lead, and ranking window functions.

## Query Details
- Table Name: {{Table Name}}
- Target Operation: {{Target Operation}}
- Partition Field: {{Partition Field}}
- Order Field: {{Order Field}}

---

Source: [SQL Window Functions Helper on PromptBuild](https://promptbuild.io/prompt/FG80welOZQWmZwOFPyN8/sql-window-functions-helper)
