Introduction to Structured Query Language for Data Analytics (SF22SQL1001) — Day 8

We are two (2) more sessions away from the SF22SQL1001 final.

We have covered lots of material —

  1. getting data from tables/views (SELECT... FROM...),
  2. joining tables/views (INNER|LEFT|RIGHT JOIN) to make larger datasets,
  3. filtering the output of queries (WHERE),
  4. ordering the output of queries (ORDER BY),
  5. grouping the output of queries when using aggregate functions (GROUP BY),
  6. adding logic to queries (CASE... WHEN... THEN... END),
  7. pushing new values into tables (INSERT INTO),
  8. deleting selected rows (DELETE FROM) from a table,
  9. deleting all rows (TRUNCATE) from a table,
  10. making data objects (CREATE),
  11. deleting objects (DROP)
  12. modifying objects (ALTER)
  13. and much more.

I hope you have been having lots of fun.

Download the class notes for day 8 — 22 pages’ worth of material.

Introduction to Structured Query Language for Data Analytics (SF22SQL1001) — Day 4

We continue working with functions. Some affect strings (RIGHT, LEFT, SUBSTRING, etc.) while others affect numbers (TIME, DATE, FORMAT, etc.) as well as aggregate functions, which need the GROUP BY clause.

    SELECT field1,
      aggregate_function(field2),
      field3
       -- other fields if any
    FROM table1
    INNER|LEFT|RIGHT JOIN table2
      ON table1.shared_data1 = table2.shared_data2
        AND table1.shared_data2 = table2.shared_data2
       -- other tables if any
    WHERE condition1
      AND|OR condition2
      -- other conditions if any
    GROUP BY field1
    ORDER BY field1 ASC|DESC,
      field2 ASC|DESC,
      field3 ASC|DESC,
      ...; -- other fields if any

Download the class notes for day 4.