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.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.