tool.sql_queries.1652b99c183e58c4
SkillDatabases & dataWrite correct, performant SQL across all major data warehouse dialects
Use tool.sql_queries.1652b99c183e58c4 in Claude, ChatGPT or Ahel Desktop
Free. Sign in, add tool.sql_queries.1652b99c183e58c4 and connect your AI. About a minute.
Also: Claude Code · Cursor · Codex
Then ask your AI: use the tool.sql_queries.1652b99c183e58c4 skill
Details
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; Ahel provides instructions and does not run this skill.
No other account needed.
Add Ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
What this skill tells your AI
The instructions your AI receives, as published by ai45lab/openart in openart-tools/tool.sql_queries.1652b99c183e58c4/SKILL.md and read by Ahel’s review.
Use this skill when the OpenART registry selects tool.sql_queries.1652b99c183e58c4 for the current task.
SQL Queries Skill
Write correct, performant, readable SQL across all major data warehouse dialects.
Dialect-Specific Reference
PostgreSQL
- Date arithmetic:
date_column + INTERVAL '7 days',DATE_TRUNC('month', created_at) - String:
ILIKE, regex with~,SPLIT_PART() - JSON:
data->>'key',data#>>'{path,to,key}' - Arrays:
ARRAY_AGG(),ANY(),@>containment - Performance:
EXPLAIN ANALYZE, partial indexes,EXISTSoverIN
Snowflake
- Date arithmetic:
DATEADD(day, 7, date_column),DATEDIFF() - Semi-structured:
column:key::stringdot notation,LATERAL FLATTEN() - Performance: clustering keys, partition pruning,
RESULT_SCAN()
BigQuery
- Date arithmetic:
DATE_ADD(),DATE_DIFF(),DATE_TRUNC(date, MONTH) - No ILIKE — use
LOWER(),REGEXP_CONTAINS() - Arrays:
UNNEST(),ARRAY_AGG() - Performance: always filter on partition columns,
APPROX_COUNT_DISTINCT(), avoidSELECT *
Redshift
- Date arithmetic:
DATEADD(),DATEDIFF(),DATE_TRUNC() - String:
ILIKE,LISTAGG() - Performance:
DISTKEY,SORTKEY,ANALYZE,VACUUM
Databricks SQL
- Delta Lake: time travel with
TIMESTAMP AS OF,MERGE INTOfor upserts - Performance:
OPTIMIZE,ZORDER,CACHE TABLE
Common SQL Patterns
Window Functions
ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY created_at DESC)
SUM(revenue) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
LAG(value, 1) OVER (PARTITION BY entity ORDER BY date)
revenue / SUM(revenue) OVER () as pct_of_total
CTEs for Readability
WITH
base_users AS (SELECT ...),
user_metrics AS (SELECT ... FROM base_users ...),
summary AS (SELECT ... FROM user_metrics ...)
SELECT * FROM summary;
Cohort Retention
WITH cohorts AS (
SELECT user_id, DATE_TRUNC('month', first_activity_date) as cohort_month
FROM users
),
activity AS (
SELECT user_id, DATE_TRUNC('month', activity_date) as activity_month
FROM user_activity
)
SELECT cohort_month, COUNT(DISTINCT user_id) as cohort_size,
COUNT(DISTINCT CASE WHEN activity_month = cohort_month THEN user_id END) as month_0,
COUNT(DISTINCT CASE WHEN activity_month = cohort_month + INTERVAL '1 month' THEN user_id END) as month_1
FROM cohorts LEFT JOIN activity USING (user_id)
GROUP BY cohort_month;
Funnel Analysis
Use conditional aggregation with MAX(CASE WHEN event = 'X' THEN 1 ELSE 0 END) per step, then compute conversion rates between steps.
Deduplication
WITH ranked AS (
SELECT *, ROW_NUMBER() OVER (PARTITION BY entity_id ORDER BY updated_at DESC) as rn
FROM source_table
)
SELECT * FROM ranked WHERE rn = 1;
Error Handling and Debugging
- Syntax errors: Check dialect-specific syntax differences
- Column not found: Verify column names, check case sensitivity
- Type mismatches: Cast explicitly (
CAST(col AS DATE)) - Division by zero: Use
NULLIF(denominator, 0) - Ambiguous columns: Always qualify with table alias in JOINs
- Group by errors: All non-aggregated columns must be in GROUP BY
Signals
- GitHub stars
- 231
- Forks
- 25
- Last commit
- Oct 2026
Advanced
- Item type
- skill
- Key
tool-sql-queries-1652b99c183e58c4- Source
- github.com/ai45lab/openart
Related picks
Skill · kilo-org
The pick for BigQuerybigquery-public
Skill · clawbio
The pick for BigQuerysupabase-postgres-best-practices
Skill · baekenough
The pick for Postgresoptimizing-snowflake-workloads
Skill · unknown-333
The pick for SnowflakeSnowflake Automation
Skill · composio-community
The pick for Snowflakebigquery-basics
Skill · davila7
The pick for BigQuery