Skip to content

Instantly share code, notes, and snippets.

@amit08255
Last active February 3, 2023 12:13
Show Gist options
  • Save amit08255/1b149a8c7b09147b3dca58766725bf15 to your computer and use it in GitHub Desktop.
Save amit08255/1b149a8c7b09147b3dca58766725bf15 to your computer and use it in GitHub Desktop.
SQL cheatsheet

SQL Cheatsheet

Get all columns in rows by distinct value in one column

select distinct on (category) * from "TargetGoal";

Select a column as boolean

(select (case when exists (SELECT id FROM user WHERE membership = 1244) then 1 else 0 end)) as column_name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment