Practical SQL Examples
SELECT Queries
Example: SELECT name, age FROM Employees WHERE age > 30; retrieves employees older
than 30.
Joins
Example: SELECT [Link], d.department_name FROM Employees e JOIN Departments d ON
e.dept_id = [Link]; combines data from two tables.
Subqueries
Example: SELECT name FROM Employees WHERE salary > (SELECT AVG(salary) FROM
Employees); finds employees earning above average.
Aggregations
Example: SELECT department_id, COUNT(*) FROM Employees GROUP BY department_id;
counts employees per department.
Sorting & Filtering
Example: SELECT * FROM Products WHERE price BETWEEN 50 AND 200 ORDER BY price
DESC; filters and sorts product data.