I might add that if you're wondering about how the SPC tools work, read the comments in the SQL. I deliberately set out to write comments that would be helpful both to experienced SPC folks and to curious beginners.
Unfortunately the GitHub Linguist grammar for SQL doesn't recognize PostgreSQL comments, so highlighting will be wonky in places.