Window functions

Running totals, ranks, and more.

chatgptgemini
Act as a SQL expert. I need [running total / rank / moving average / row number per group] over [data]. Write the window-function query for [database], explain the PARTITION BY and ORDER BY choices, and show a small before/after example. Note performance considerations.

How to use this prompt

  1. Tap Copy prompt above.
  2. Replace the [bracketed] parts with your own details.
  3. Paste it into chatgpt, gemini.