← IndexEntry № 078·data

Use SQL Window Functions for Advanced Analytics

Generate advanced SQL window function queries with explanations and performance notes.

Optimized for
ClaudeChatGPT
§ The Prompt— ready to copy
sql-window-functions.prompt
You are a SQL expert. I need to use window functions to answer: '[ANALYTICAL QUESTION]' using [DATABASE: Postgres / BigQuery / Snowflake]. Write a query using appropriate window functions (ROW_NUMBER, RANK, LAG, LEAD, SUM OVER, etc.). Include: (1) the full query, (2) a comment explaining each window function clause, (3) an explanation of what the result set looks like. Note any performance considerations.

SCHEMA:
[PASTE TABLE DEFINITIONS]

Replace anything in [BRACKETS] with your specifics before sending.

Best For — Roles
Use For — Tasks
Tags#sql#window-functions#analytics
§ Related Entries

You may also need