1๏ธโฃ SELECT
โ Used to retrieve specific columns from a table.
SELECT name, age FROM users;
2๏ธโฃ WHERE
โ Filters rows based on a condition.
SELECT * FROM sales WHERE region = 'North';
3๏ธโฃ GROUP BY
โ Groups rows that have the same values into summary rows.
SELECT region, SUM(sales) FROM sales GROUP BY region;
4๏ธโฃ ORDER BY
โ Sorts the result by one or more columns.
SELECT * FROM customers ORDER BY created_at DESC;
5๏ธโฃ JOIN
โ Combines rows from two or more tables based on a related column.
SELECT a.name, b.salary
FROM employees a
JOIN salaries b ON a.id = b.emp_id;
6๏ธโฃ COUNT() / SUM() / AVG() / MIN() / MAX()
โ Common aggregate functions for metrics and summaries.
SELECT COUNT(*) FROM orders WHERE status = 'completed';
7๏ธโฃ HAVING
โ Filters after a GROUP BY (unlike WHERE, which filters before).
SELECT department, COUNT(*) FROM employees GROUP BY department HAVING COUNT(*) > 10;
8๏ธโฃ LIMIT
โ Restricts number of rows returned.
SELECT * FROM products LIMIT 5;
9๏ธโฃ CASE
โ Implements conditional logic in queries.
SELECT name,
CASE
WHEN score >= 90 THEN 'A'
WHEN score >= 75 THEN 'B'
ELSE 'C'
END AS grade
FROM students;
๐ DATE functions (NOW(), DATE_PART(), DATEDIFF(), etc.)
โ Handle and extract info from dates.
SELECT DATE_PART('year', order_date) FROM orders;Join our WhatsApp channel: https://whatsapp.com/channel/0029VbAbnvPLSmbeFYNdNA29
๐ Tap โค๏ธ for more!