What are SQL Clauses?
SQL clauses are used to filter, sort, group, and organize query results.
WHERE
ORDER BY
GROUP BY
HAVING
WHERE Clause
- The WHERE clause filters records based on a condition.
SELECT *
FROM Employee
WHERE Salary > 50000;
ORDER BY Clause
- The ORDER BY clause sorts the result in ascending or descending order.
SELECT *
FROM Employee
ORDER BY Salary DESC;
GROUP BY Clause
- The GROUP BY clause groups rows that have the same values.
SELECT Department, COUNT(*)
FROM Employee
GROUP BY Department;
HAVING Clause
- The HAVING clause filters grouped data.
SELECT Department, COUNT(*)
FROM Employee
GROUP BY Department
HAVING COUNT(*) > 5;
Top comments (0)