Here’s a cheatsheet to summarise the basic functions covered in this SQL Tutorial Series. Function Syntax AND / OR SELECT column_name FROM table_name WHERE condition AND/OR condition IN SELECT column_name FROM table_name WHERE column_name IN (value1,value2,value3…...) GROUP BY SELECT column_name, aggregate_function(column_name) FROM table_name WHERE condition GROUP BY column_name HAVING SELECT column_name, aggregate_function(column_name) FROM table_name … Continue reading SQL Tutorial 7 : Summary & Cheatsheet
Category: Uncategorized
Now that we have explored querying data from a single table, we must also consider the fact that more often than not, the columns that we require can lie in different tables. To query data from multiple tables, we will need to use the JOIN function. A more detailed explanation of JOINs can be found … Continue reading SQL Tutorial 6 : “JOIN” Function
The “HAVING” function can be described as a WHERE function, but used for Aggregation functions. For instance, a query which includes “WHERE sum(product_orders) > 10” will not work. Instead of using the WHERE function in such a scenario, the HAVING function will be used. (ie HAVING sum(product_orders) > 10) To illustrate, let's go back to … Continue reading SQL Tutorial 5 : “HAVING” Function
“GROUP BY” Function The “GROUP BY” statement is used with the aggregate functions such as SUM and COUNT to group the result-set by one or more columns. Again, let’s use the same ”world_data” dataset to illustrate this. Consider that we want to find the total gdp of each continent from this dataset. We will write … Continue reading SQL Tutorial 4 : “GROUP BY” & “ORDER BY” Functions