Pseudo Random Nonsense Generator

SQL

ยท note

Max (and Min)

grabs from 1 column

table: Networth

NetWorthInMillions Yob
50 1989
10 1992
30 1995
5 1899

SELECT MAX(NetWorthInMillions) from Networth;

50

Greatest (and Least)

max per row, across multiple columns

  • useful when you have comparable figures across multiple columns (e.g. quarterly revenue, q1, q2, q3, q4)

table: Distances

distance_to_home distance_to_work
10 20
5 1

SELECT GREATEST(distance_to_home, distance_to_work) from Distances

20
5

Coalesce

  • shorthand for Case
  • sorta works like filter on an array

returns FIRST non-null argument

Interval

used for analyzing stuff

  • if i want to get a list of sign ins, but one month after

returns index of the argument that is less than the first argument

In

SELECT NetWorthInMillions from Actors where FirstName IN(Tom, Kim);