wiki.hjertnes.website

SQL

Random SQL notes

  • where is before group byhaving is after
  • INNER JOIN: The INNER JOIN keyword selects all rows from both the tables as long as the condition satisfies.
  • LEFT JOIN: This join returns all the rows of the table on the left side of the join and matching rows for the table on the right side of join.
  • RIGHT JOIN: RIGHT JOIN is similar to LEFT JOIN. This join returns all the rows of the table on the right side of the join and matching rows for the table on the left side of join
  • FULL JOIN: FULL JOIN creates the result-set by combining result of both LEFT JOIN and RIGHT JOIN. The result-set will contain all the rows from both the tables.
  • SELECT depname, empno, salary, avg(salary) OVER (PARTITION BY depname) FROM empsalary; "avg(salary) OVER (PARTITION BY depname)"
  • explain: shows what queryies does

Backlinks