Mastering SQL is essential for data analysts. Here are the most commonly used SQL commands and functions that help extract, manipulate, and summarize data efficiently.
1️⃣ SELECT – Retrieve Data
Use it to fetch specific columns from a table.
SELECT name, age FROM employees;
2️⃣ FROM – Specify Table
Tells SQL where to pull the data from.
SELECT * FROM sales_data;
3️⃣ WHERE – Filter Data
Applies conditions to filter rows.
SELECT * FROM customers WHERE city = 'Delhi';
4️⃣ GROUP BY – Aggregate by Categories
Groups rows based on one or more columns for aggregation.
SELECT department, COUNT(*) FROM employees GROUP BY department;
5️⃣ HAVING – Filter After Grouping
Filters groups after GROUP BY (unlike WHERE, which filters rows).
SELECT category, SUM(sales)
FROM orders
GROUP BY category
HAVING SUM(sales) > 10000;
6️⃣ ORDER BY – Sort Results
Sorts the result set in ascending or descending order.
SELECT name, salary FROM employees ORDER BY salary DESC;
7️⃣ COUNT() – Count Records
Counts number of rows or non-null values.
SELECT COUNT(*) FROM products;
8️⃣ SUM() – Total Values
Calculates the sum of numeric values.
SELECT SUM(amount) FROM transactions;
9️⃣ AVG() – Average Values
Returns the average of numeric values.
SELECT AVG(price) FROM items;
🔟 JOIN – Combine Tables
Combines rows from multiple tables based on related columns.
SELECT a.name, b.order_date
FROM customers a
JOIN orders b ON a.id = b.customer_id;
SQL Resources: https://whatsapp.com/channel/0029VanC5rODzgT6TiTGoa1v
💬 Tap ❤️ for more!