Commit 5a5c49f
committed
docs(sql): add detailed explanation for GROUP BY clause under dedicated folder
What
- Created `Group By Clauses In SQL` folder to document usage and behavior of the `GROUP BY` clause.
- Explained how `GROUP BY` groups rows that share common values in specified columns.
- Highlighted its common pairing with aggregate functions (`COUNT`, `SUM`, `AVG`, `MIN`, `MAX`).
- Clarified difference between `WHERE` (filters before grouping) and `HAVING` (filters after grouping).
- Added conceptual overview and best practices for applying `GROUP BY`.
Why
- Developers often struggle to distinguish `WHERE` vs `HAVING` in grouped queries.
- Centralized documentation improves clarity and serves as a quick reference for query writing.
- Real-world SQL queries frequently require grouping for analytics, reports, and dashboards.
How
- Structured explanation with:
- Definition and purpose of `GROUP BY`.
- Common syntax examples: `SELECT column, COUNT(*) FROM table GROUP BY column;`.
- Use cases with multiple columns in grouping.
- Integration with aggregate functions and `HAVING`.
- Positioned folder as foundation for more advanced aggregation topics (ROLLUP, CUBE, GROUPING SETS).
Key notes
- `GROUP BY` must come after `WHERE` and before `HAVING` in query order.
- Columns in `SELECT` must either appear in `GROUP BY` or be used inside aggregate functions.
- Improper grouping can cause SQL errors or misleading results.
Real-life applications
- Sales reports: group transactions by `region` or `salesperson`.
- HR analytics: count employees by `department`.
- Finance: aggregate expenses by `month` or `category`.
- E-commerce: compute product sales counts grouped by `category`.
Future improvements
- Add runnable SQL examples with sample tables.
- Cover performance considerations with large datasets (e.g., indexing grouped columns).
- Extend with advanced grouping features supported by modern SQL dialects (e.g., PostgreSQL, Oracle, SQL Server).
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent bc9cf06 commit 5a5c49f
File tree
2 files changed
+0
-0
lines changed- Section28JDBCusingSQLite/Clauses in SQL/Group By Clauses In SQL
2 files changed
+0
-0
lines changed
0 commit comments