Commit 8e76f8c
committed
docs(sql): add dedicated folder for ORDER BY clause with detailed explanation
What
- Created `Order By Clauses In SQL` folder to document the `ORDER BY` clause.
- Explained how it sorts query results in ascending (ASC) or descending (DESC) order.
- Added syntax and examples for ordering single or multiple columns.
- Covered default behavior (ASC if not specified).
Why
- Sorting results is one of the most common SQL operations.
- Developers often confuse default sort order or struggle with multi-column sorting.
- Clear documentation helps ensure predictable and optimized query results.
How
- Structured the content into:
- Definition and role of `ORDER BY`.
- Syntax examples:
`SELECT name, salary FROM employees ORDER BY salary DESC;`
- Multi-column ordering:
`SELECT name, dept, salary FROM employees ORDER BY dept ASC, salary DESC;`
- Explanation of ASC vs DESC, default order, and null handling.
- Compared `ORDER BY` usage across different SQL dialects (MySQL, PostgreSQL, SQL Server, Oracle).
Key notes
- Default sort order is ascending (ASC).
- Multiple columns can be sorted independently (ASC or DESC).
- `ORDER BY` is applied after filtering (`WHERE`) and grouping (`GROUP BY`, `HAVING`).
- Sorting large datasets can impact performance if not indexed.
Real-life applications
- HR: list employees by hire date (newest to oldest).
- Finance: rank accounts by transaction value.
- Sales: display products ordered by highest revenue first.
- Education: show students ordered by grades or roll numbers.
Future improvements
- Add examples with `ORDER BY` + aggregate functions.
- Cover advanced cases like sorting with expressions, CASE statements, or custom collations.
- Include performance tuning tips with indexes for faster sorting.
Signed-off-by: https://github.com/Someshdiwan <[email protected]>1 parent bf1f40d commit 8e76f8c
File tree
4 files changed
+0
-0
lines changed- Section28JDBCusingSQLite/Clauses in SQL/Order By Clauses In SQL
4 files changed
+0
-0
lines changed
0 commit comments