SQL Basics

When using SQL (Structured Query Language), the order of operation is very important. Below is the order of operation to help you get it write:

  1. Select -  This is similar to the select tool within Alteryx, in that it allows us to select the specific data we require from the database.

Syntax: SELECT ”column_name” or SELECT DISTINCT “column_name” which allows you to return only different values.

Example: SELECT * - The asterisk selects all the data from your data source.

2. From - Specify which table to select data from.

Syntax: FROM ”table_name”

Example: FROM "Superstore_Orders"

3. Where - This clause is used to extract information for records that fulfill your specific criterion.

Syntax: WHERE “column_name” operator value;

Example: WHERE “Region” = 'Central' and “Sales” > 1000

4. Group By - Similar to the summarise tool in Alteryx in that it allows us to aggregate to the dimension level.

Syntax: GROUP BY column_name

Example: GROUP BY "State"

5. Having - Similar to the WHERE clause for but for aggregated functions.

Syntax: aggregate_function(column_name) operator value

Example: HAVING AVG ("Profit") > 500

6. Order By - Used to sort the result set in ascending or descending order.

Syntax: ORDER BY column_name DESC/ASC

Example: ORDER BY AVG("Profit") DESC

Author:
Arnold Quarcoo
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2025 The Information Lab