# SQL Queries Error Handling And Debugging

> Sub-skill of sql-queries: Error Handling and Debugging.

- Skill: `vamseeachanta/sql-queries-error-handling-and-debugging` (Agent Skill)
- Install (CLI): `npx skillmds@latest add vamseeachanta/sql-queries-error-handling-and-debugging`
- Raw SKILL.md: https://api.skillmd.com/api/skills/vamseeachanta/sql-queries-error-handling-and-debugging/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Data & Analytics
- Author: vamseeachanta (https://skillmd.com/u/vamseeachanta)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/vamseeachanta/sql-queries-error-handling-and-debugging

---


# Error Handling and Debugging

## Error Handling and Debugging


When a query fails:

1. **Syntax errors**: Check for dialect-specific syntax (e.g., `ILIKE` not available in BigQuery, `SAFE_DIVIDE` only in BigQuery)
2. **Column not found**: Verify column names against schema -- check for typos, case sensitivity (PostgreSQL is case-sensitive for quoted identifiers)
3. **Type mismatches**: Cast explicitly when comparing different types (`CAST(col AS DATE)`, `col::DATE`)
4. **Division by zero**: Use `NULLIF(denominator, 0)` or dialect-specific safe division
5. **Ambiguous columns**: Always qualify column names with table alias in JOINs
6. **Group by errors**: All non-aggregated columns must be in GROUP BY (except in BigQuery which allows grouping by alias)

