Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SQL Workshop Part 1

SQL Workshop Part 1

This is Part 1 of the SQL workshop series I am hosting for people to empower them getting the most out of the data they are storing.

Lukas Rieder

May 24, 2017
Tweet

More Decks by Lukas Rieder

Other Decks in Education

Transcript

  1. 3 Hands-On SELECT * FROM retailers
 WHERE created_at >= NOW()

    - INTERVAL '1 week' Selecting specific rows
  2. 3 Hands-On name = 'Ferry-Olson'
 website IS NULL
 created_at >=

    CAST('2017-05-01' AS date)
 
 column operator column or value conditions
  3. 3 Hands-On WHERE (A OR B) AND (X OR Y)

    Parentheses control condition precedence
  4. 3 Hands-On From table to visualisation day count 1 345

    2 300 3 399 0 100 200 300 400 day 1 day 2 day 3
  5. 3 Hands-On SELECT CAST(created_at AS date) AS day, COUNT(*)
 FROM

    products
 GROUP BY CAST(created_at AS date) Slicing data aggregates
  6. 3 Hands-On SELECT CAST(created_at AS date) AS day, COUNT(*)
 FROM

    products
 GROUP BY date_trunc('hour', created_at) Slicing aggregates by specific time ranges