Last active
October 19, 2020 12:49
-
-
Save whal-e3/60d3e2a2401a86272cb5fe1f39702bc0 to your computer and use it in GitHub Desktop.
PostgreSQL 13 cheat sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT COUNT(DISTINCT(*)) FROM _somewhere_ | |
WHERE _something_ <= 12 AND _something2_ = '_word_' | |
WHERE _something_ BETWEEN 8 AND 9 | |
WHERE _something_ IN (0.99, 1.98, 1.99) | |
WHERE _something_ LIKE/ILIKE '_J%' | |
ORDER BY _something_ ASC, _something2_ DESC | |
LIMIT 5; | |
---------------------------------------------------------------------------------- | |
MAX, MIN, AVG & ROUND, SUM | |
* GROUP BY - think blocks with same value as one block and operate aggregation function | |
SELECT col_1, col_2, aggregation_function(col_3) FROM table | |
GROUP BY aggregation_function(col_3) | |
ORDER BY ~ ~ | |
~ | |
HAVING |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment