What is SQL?
SQL stands for Structured Query Language and lets you access and manipulate databases.
How to SQL:
The order below is the structure you need to follow when writing SQL in Snowflake. Its similar to the flows of Alteryx (e.g. Input tool, Filter tool, select tool, summarize)
![](https://www.thedataschool.co.uk/content/images/2022/08/image-149.png)
To bring tables into view from snowflake:
- SELECT * - bring in all the data
- FROM "...." - which data file we are bringing in
- Use double quotes when specifying a column header/name & single for values in the rows
![](https://www.thedataschool.co.uk/content/images/2022/08/image-319.png)
- SELECT DISTINICT "...." - Only the Column specified will show in the dataset [can have multiple columns specified = SELECT DISTINCT "...", "...", "..."]
![](https://www.thedataschool.co.uk/content/images/2022/08/image-322.png)
Preview datasets to make life a little bit easier:
You can also preview data from any dataset - this is a good idea if you are trying to transform a dataset and you want to compare it to the original dataset.
In this case, it would be a good idea to have the original dataset as a preview dataset. So when you make changes and want to compare, you can easily switch between the results window and the data preview window.
![](https://www.thedataschool.co.uk/content/images/2022/08/image-320.png)
Some Code for SQL:
![](https://www.thedataschool.co.uk/content/images/2022/08/image-323.png)
![](https://www.thedataschool.co.uk/content/images/2022/08/image-324.png)
Answering questions using SQL:
![](https://www.thedataschool.co.uk/content/images/2022/08/image-325.png)
![](https://www.thedataschool.co.uk/content/images/2022/08/image-326.png)