SQL Tools
SQL tooling: formatting, keyword lookup and statement reference covering SELECT clause execution order, JOIN selection, aggregate versus window functions, and the WHERE/HAVING stage difference.
SQL is the standard language for interacting with databases, with many details and per-database dialect differences.
Approach Comparison
| Aspect | WHERE | HAVING |
|---|---|---|
| When it runs | Before GROUP BY | After GROUP BY |
| Can use SELECT aliases | No | Yes |
| Can aggregate | No | Yes |
| Operates on | Individual rows | Grouped result set |
| Index usage | Can use an index | Usually cannot |
| Typical use | Filter detail rows | Filter aggregates (count > 100) |
| Common mistake | Putting aggregate conditions here | Used as a WHERE substitute |
| NULL semantics | Use IS NULL to match empties | Same |
Edge Cases
- Adding an aggregate condition to WHERE raises a non-aggregated column error, because it runs before grouping.
- HAVING can use SELECT aliases while WHERE cannot — a direct consequence of execution order.
- Filtering a right-side column in WHERE degrades a LEFT JOIN into an INNER JOIN; put such conditions in ON instead.
- COUNT(*) counts rows while COUNT(column) skips NULLs, so results can differ substantially.
Common Pitfalls
- Writing an aggregate filter in WHERE and only switching to HAVING after the error, when the condition was in the wrong stage all along.
- Putting a left-side condition in the LEFT JOIN ON clause, which filters nothing and produces a cartesian product.
- Assuming HAVING replaces WHERE, discarding detail rows before aggregation.
- Using NOT IN against a subquery containing NULL, which returns nothing; use NOT EXISTS or filter the NULLs first.
Related Tools
- SQL FormatterFormat and indent SQL queries with a regex-based prettifier for SELECT, INSERT and UPDATE statements, keeping comments and uppercasing keywords. Keeps comments.
- Text ReplacerFind and replace text with case-sensitive, whole-word and regex matching. Replace all at once with live preview, and review every hit before applying.
- Case ConverterConvert text between camelCase, snake_case, kebab-case, PascalCase and CONSTANT_CASE instantly. Switch naming styles for code, configs and identifiers.
- Regex TesterTest JavaScript regular expressions with flags like g, i, m, s and u plus capture groups, listing every match and named group as you type. All hits listed.