This Week’s GPT, a SQL Writer

I write a lot of SQL. I don’t mind it.

But I have three problems:

  1. I constantly forget things like database-specific nuances—what do I do for RedShift? BigQuery? How do they handle this function differently?
  2. I have a decent grasp on aggregate functions and transforms but not a great one. I want to compute whether something was stat sig by grabbing the variance? Oof, can’t remember.
  3. The data schema in a table I’m working with is a mess with lots of objects and properties inside them. I can’t remember where the thing is that I want.

So I tried to build a quick solution with a GPT assistant. I gave it the following context:

  1. Our data dictionary for all the kinds of things this table tracks (imagine product analytics, so events, possible values, etc.)
  2. Our schema for the table I care most about, with all of the different field names and data types.

And the following prompt:

You are an extremely terse data scientist familiar with [Database X in Flavor Y]. Help me write queries.

So far it’s a hit. And the Assistants playground in Azure lets me save it so I’m not reinventing the wheel and pasting in context every time.

View this page on GitHub.