SQL: Difference between revisions

From David's Wiki
(Created page with "SQL basics ==Common functions== See [https://www.postgresql.org/docs/16/functions-math.html Postgres math functions] and [https://www.postgresql.org/docs/current/functions-conditional.html Postgres conditional functions]. * Average * Sum * Round * [https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL Coalesce] - return the first non-null parameter. * [https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIO...")
 
Line 3: Line 3:


==Common functions==
==Common functions==
See [https://www.postgresql.org/docs/16/functions-math.html Postgres math functions] and [https://www.postgresql.org/docs/current/functions-conditional.html Postgres conditional functions].
===Math functions===
 
See [https://www.postgresql.org/docs/16/functions-math.html Postgres math functions]
* Average
* Average
* Sum
* Sum
* Round
* Round
===Conditional functions===
See  [https://www.postgresql.org/docs/current/functions-conditional.html Postgres conditional functions].
* [https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL Coalesce] - return the first non-null parameter.
* [https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL Coalesce] - return the first non-null parameter.
* [https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-CASE Case]
* [https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-CASE Case]

Revision as of 01:43, 12 February 2024

SQL basics


Common functions

Math functions

See Postgres math functions

  • Average
  • Sum
  • Round

Conditional functions

See Postgres conditional functions.

Joins

Joins merge two tables into a single table. You can think of this like an outer product, applying some conditions to subset from every possible combination of rows from the two tables.

  • Inner join - creates rows only if keys match between the rows
  • Left join - keep all rows from the left table
  • Right join - keep all rows from the right table
  • Outer join - keep rows from both tables.

Subqueries