diff --git a/reference.md b/reference.md index c755c27f..4955789f 100644 --- a/reference.md +++ b/reference.md @@ -6,3 +6,80 @@ layout: reference See [this cheat sheet]({{ page.root }}{% link files/sql-cheat-sheet.md %}) for an list of the commands covered in this lesson. + +### Keywords Description Summary + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeywordDefinitionExampleDescription
SELECT Select data from database or table SELECT * Selects the entire dataset
SELECT column1 Selects a particular column
SELECT 1 + 2Performs a calculation
FROMIndicates the table from which the data is selected or deletedSELECT year
FROM surveys
Query will display the desired column from the table
WHEREFilter the result set so that only the values satisfying the condition are includedSELECT *
FROM surveys
WHERE year == 1990
Query will display all values from the table for which the year is 1990
LIMITRetrieves the number of records from the table up to the limit valueSELECT *
FROM surveys
LIMIT 5
Query will will return only the first 5 rows from the table
DISTINCTSelect distinct valuesSELECT DISTINCT year
FROM surveys
Query will display the distinct years present on the table
ASUsed as an alias to rename the column or tableSELECT 1 + 2 AS calcColumn will be renamed to "calc"
GROUP BYGroups the result setSELECT MAX(weight)
FROM surveys
GROUP BY year
Query will display the max weight per year
HAVINGUsed to filter grouped rows when using aggregate functionsSELECT MAX(weight)
FROM surveys
GROUP BY year HAVING MAX(weight) > 100
Filter the results by the years that have a maximum weight greater than 100g
JOIN Joins tablesSELECT *
FROM surveys
JOIN species
ON surveys.species_id = species.species_id
Query will display all the columns from both tables where the condition is met