Skip to content

Instantly share code, notes, and snippets.

@malkab
Last active January 11, 2021 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malkab/2364c95cf4b7b13b560bda65cdb0f8c1 to your computer and use it in GitHub Desktop.
Save malkab/2364c95cf4b7b13b560bda65cdb0f8c1 to your computer and use it in GitHub Desktop.
PostgreSQL - Cheatsheet & Reminders

PostgreSQL Cheatsheet & Reminders

Some hints and important stuff about PostgreSQL.

Reordering columns in existing tables with data: never do that, pointers to data seems to be lost. Redo the table if needed with create select and such.

Avoiding divisions by zero: the nullif function is an useful way to avoid them:

 round(((sum(e001518)::float) / (nullif(sum(e166418), 0))::float)::numeric, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment