Uploaded by Ezequiel Robles

SQL-V1

advertisement
By @AbzAaron
https://twitter.com/AbzAaron
Common Commands
SELECT
AS
FROM
WHERE
JOIN
AND
OR
LIKE
IN
IS NULL
LIMIT
CASE
CREATE
DROP
UPDATE
DELETE
ALTER TABLE
GROUP BY
ORDER BY
HAVING
SUM
AVG
MIN
MAX
COUNT
Examples
Joins
Select all rows from table with filter applied
Select data from database
Rename column or table with alias
Specify table we’re pulling from
Filter query to match a condition
Combine rows from 2 or more tables
Combine conditions in a query. All must be met
Combine conditions in a query. One must be met
Search for patterns in a column
Specify multiple values when using WHERE
Return only rows with a NULL value
Limit the number of rows returned
Return value on a specified condition
Select first 10 rows for 2 columns
Select all rows with multiple filters applied
Select all rows from col1 and col2 ordering by col1
Create TABLE, DATABASE, INDEX or VIEW
Delete TABLE, DATABASE, or INDEX
Update table data
Delete rows from a table
Add/Remove columns from table
Return count of rows in table
Return sum of col1
Group rows that have same values into summary rows
Set order of result. Use DESC to reverse order
Same as WHERE but used for aggregate functions
Return sum of column
Return average of column
Return min value of column
Return max value of column
Count number of rows
Return max value from col1
Computer summary statistics by grouping col2
Combine data from two tables using a left join
Aggregate and filter results
Create
Update Table
Delete Records
Order of
Execution
FROM
Implementation of CASE statement
WHERE
GROUP BY
Delete
Add/Remove Column
HAVING
SELECT
ORDER BY
LIMIT
Sources:
https://www.dataquest.io/blog/sql-commands/#t-1613505022898
https://www.dataquest.io/blog/sql-joins-tutorial/
Download