Skip to content

Commit bf1f40d

Browse files
committed
docs(sql): add dedicated folder for HAVING clause with detailed explanation
What - Created `HAVING Clauses In SQL` folder to document the role and usage of the `HAVING` clause. - Explained how `HAVING` is used to filter aggregated/grouped data after applying `GROUP BY`. - Highlighted difference between `WHERE` (row-level filtering) and `HAVING` (group-level filtering). - Provided syntax, rules, and examples for clarity. Why - Many developers confuse `WHERE` and `HAVING` when writing aggregate queries. - Proper documentation helps reinforce that `HAVING` operates on grouped results, not individual rows. - Essential for analytics, reporting, and dashboards that require grouped filtering. How - Structured the content into: - Definition and purpose of `HAVING`. - Syntax examples: `SELECT dept, COUNT(*) FROM employees GROUP BY dept HAVING COUNT(*) > 5;` - Explanation of how it follows `GROUP BY` in query order. - Edge cases and common mistakes (e.g., using `HAVING` without aggregation). - Connected examples with real-life business use cases. Key notes - `HAVING` must be used with `GROUP BY` when filtering aggregated results. - You can use aggregate functions directly in `HAVING` conditions. - Without `GROUP BY`, `HAVING` can still filter on aggregate over the entire table. Real-life applications - HR: list departments with more than 10 employees. - Sales: find products whose total sales exceed $1000. - Education: show courses with an average score below a threshold. - Finance: display accounts with total transactions over a set limit. Future improvements - Add combined examples with `WHERE` + `GROUP BY` + `HAVING`. - Cover performance considerations when using `HAVING` on large datasets. - Include advanced SQL dialect support (MySQL, PostgreSQL, Oracle, SQL Server differences). Signed-off-by: https://github.com/Someshdiwan <[email protected]>
1 parent 5a5c49f commit bf1f40d

File tree

1 file changed

+0
-0
lines changed

1 file changed

+0
-0
lines changed

0 commit comments

Comments
 (0)