SQL cheat sheet
Retrieve data from one or more tables
| |
Select unique values from a column
| |
Filter rows based on specified conditions
| |
Limit the number of rows returned in the result set
| |
Retrieve a specified number of rows from the result set
| |
Filter rows based on specified conditions
| |
Match a pattern in a column
| |
Match any value in a list
| |
Match values within a specified range
| |
Match NULL values
| |
Combines multiple conditions in a WHERE clause
| |
Specifies multiple conditions where any one of them should be true
| |
Negates A Condition SELECT * FROM employees WHERE NOT department = ‘IT’; ORDER BY Sorts the Result Set in Ascending or Descending Order SELECT * FROM employees ORDER BY salary DESC; GROUP BY Groups Rows that have the Same Values into Summary Rows SELECT department, COUNT(*) AS employee_count FROM employees GROUP BY department;
Count the number of rows in a result set
| |
Calculate the sum of values in a column
| |
Calculate the average value of a column
| |
Find the minimum value in a column
| |
Find the maximum value in a column
| |