ufo-ai/ufo-core/data-sql-queries
Claude Code and agent skill by ufo-ai/ufo-core
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Load before writing or tuning SQL — .sql files, schema DDL, or queries against tables.
Install
npx vskill@latest install ufo-ai/ufo-core/data-sql-queriesSKILL.md
SQL Queries
Dialect-specific reference and common analytical patterns for data warehouse SQL.
Dialect Quick Reference
Date Arithmetic
| Operation | PostgreSQL | Snowflake | BigQuery | Redshift | Databricks | |
|---|---|---|---|---|---|---|
| Add days | + INTERVAL '7 days' | DATEADD(day, 7, col) | DATE_ADD(col, INTERVAL 7 DAY) | DATEADD(day, 7, col) | DATE_ADD(col, 7) | |
| Date diff | end - start | DATEDIFF(day, start, end) | DATE_DIFF(end, start, DAY) | DATEDIFF(day, start, end) | DATEDIFF(end, start) | |
| Truncate | DATE_TRUNC('month', col) | DATE_TRUNC('month', col) | DATE_TRUNC(col, MONTH) | DATE_TRUNC('month', col) | DATE_TRUNC('MONTH', col) | |
| Extract | EXTRACT(DOW FROM col) (0=Sun) | DAYOFWEEK(col) | EXTRACT(DAYOFWEEK FROM col) (1=Sun) | DATE_PART('dow', col) | DAYOFWEEK(col) |
Case-Insensitive Matching
| Dialect | Pattern | |
|---|---|---|
| PostgreSQL, Snowflake, Redshift | ILIKE '%pattern%' | |
| BigQuery | LOWER(col) LIKE '%pattern%' |
JSON / Semi-Structured Access
| Dialect | Pattern | |
|---|---|---|
| PostgreSQL | data->>'key' (text), data#>>'{path,to,key}' (nested) | |
| Snowflake | col:key::STRING (VARIANT dot notation), LATERAL FLATTEN(input => array_col) | |
| BigQuery | UNNEST(array_col), struct_col.field_name |
Performance Tips by Dialect
- PostgreSQL:
EXPLAIN ANALYZE,EXISTSoverINfor subqueries, partial indexes - Snowflake: Clustering keys (not indexes), filter on cluster columns,
RESULT_SCAN(LAST_QUERY_ID())to reuse results - BigQuery: Always filter on partition column,
APPROX_COUNT_DISTINCT()for cardinality, avoidSELECT *(billed per byte) - Redshift: DISTKEY for collocated joins, SORTKEY for filters, watch for DS_BCAST/DS_DIST in plan
- Databricks:
OPTIMIZE+ZORDER,CACHE TABLE, partition by low-cardinality date columns
Window Functions
Common Analytical Patterns
Deduplication:
Cohort retention:
Funnel conversion:
Gotchas
- BigQuery DATE_TRUNC argument order is reversed — It's
DATE_TRUNC(col, MONTH)notDATE_TRUNC('month', col). This silently produces wrong results in some cases instead of erroring. - LAST_VALUE needs explicit frame — Without
ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING,LAST_VALUEuses the default frame that ends at the current row, giving you the current row's value back. - COUNT(DISTINCT) in window functions — Not supported in most dialects. Use a subquery or CTE to pre-aggregate instead.
- Integer division truncates silently —
5 / 2 = 2in most dialects. Cast to float first:5.0 / 2orCAST(x AS FLOAT) / y. - NULL poisons comparisons —
WHERE col != 'x'excludes NULLs. UseWHERE col IS DISTINCT FROM 'x'(Postgres) orWHERE COALESCE(col, '') != 'x'if you want NULLs included.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingextensions/repl/ufo_ext_repl/skills/data-sql-queries/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ufo-ai/ufo-core/data-sql-queries)