Write, optimize, and translate SQL across major warehouse dialects.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "sql-queries" skill from askskill: 1. Download https://raw.githubusercontent.com/anthropics/knowledge-work-plugins/main/data/skills/sql-queries/SKILL.md 2. Save it as ~/.claude/skills/sql-queries/SKILL.md 3. Reload skills and tell me it's ready
Write a BigQuery SQL query to calculate new paying users, conversion rate, and cumulative revenue by channel for the last 90 days, aggregated weekly, using CTEs for readability.
A well-structured BigQuery SQL query with CTEs, aggregations, and metric calculations.
This Snowflake query runs slowly. Analyze the bottlenecks and rewrite it to reduce scanned data and unnecessary subqueries, then explain the optimization choices: SELECT ...
An optimized SQL version plus bottleneck analysis and concrete performance recommendations.
Convert this PostgreSQL SQL into Databricks SQL, preserving the logic, and note syntax differences and required function replacements.
Ready-to-run Databricks SQL with notes on key dialect differences.
Write correct, performant, readable SQL across all major data warehouse dialects.
Date/time:
-- Current date/time
CURRENT_DATE, CURRENT_TIMESTAMP, NOW()
-- Date arithmetic
date_column + INTERVAL '7 days'
date_column - INTERVAL '1 month'
-- Truncate to period
DATE_TRUNC('month', created_at)
-- Extract parts
EXTRACT(YEAR FROM created_at)
EXTRACT(DOW FROM created_at) -- 0=Sunday
-- Format
TO_CHAR(created_at, 'YYYY-MM-DD')
String functions:
-- Concatenation
first_name || ' ' || last_name
CONCAT(first_name, ' ', last_name)
-- Pattern matching
column ILIKE '%pattern%' -- case-insensitive
column ~ '^regex_pattern$' -- regex
-- String manipulation
LEFT(str, n), RIGHT(str, n)
SPLIT_PART(str, delimiter, position)
REGEXP_REPLACE(str, pattern, replacement)
Arrays and JSON:
-- JSON access
data->>'key' -- text
data->'nested'->'key' -- json
data#>>'{path,to,key}' -- nested text
-- Array operations
ARRAY_AGG(column)
ANY(array_column)
array_column @> ARRAY['value']
Performance tips:
EXPLAIN ANALYZE to profile queriesEXISTS over IN for correlated subqueriesDate/time:
-- Current date/time
CURRENT_DATE(), CURRENT_TIMESTAMP(), SYSDATE()
-- Date arithmetic
DATEADD(day, 7, date_column)
DATEDIFF(day, start_date, end_date)
-- Truncate to period
DATE_TRUNC('month', created_at)
-- Extract parts
YEAR(created_at), MONTH(created_at), DAY(created_at)
DAYOFWEEK(created_at)
-- Format
TO_CHAR(created_at, 'YYYY-MM-DD')
String functions:
-- Case-insensitive by default (depends on collation)
column ILIKE '%pattern%'
REGEXP_LIKE(column, 'pattern')
-- Parse JSON
column:key::string -- dot notation for VARIANT
PARSE_JSON('{"key": "value"}')
GET_PATH(variant_col, 'path.to.key')
-- Flatten arrays/objects
SELECT f.value FROM table, LATERAL FLATTEN(input => array_col) f
Semi-structured data:
-- VARIANT type access
data:customer:name::STRING
data:items[0]:price::NUMBER
-- Flatten nested structures
SELECT
t.id,
item.value:name::STRING as item_name,
item.value:qty::NUMBER as quantity
FROM my_table t,
LATERAL FLATTEN(input => t.data:items) item
Performance tips:
RESULT_SCAN(LAST_QUERY_ID()) to avoid re-running expensive queriesDate/time:
-- Current date/time
CURRENT_DATE(), CURRENT_TIMESTAMP()
-- Date arithmetic
DATE_ADD(date_column, INTERVAL 7 DAY)
DATE_SUB(date_column, INTERVAL 1 MONTH)
DATE_DIFF(end_date, start_date, DAY)
TIMESTAMP_DIFF(end_ts, start_ts, HOUR)
-- Truncate to period
DATE_TRUNC(created_at, MONTH)
TIMESTAMP_TRUNC(created_at, HOUR)
-- Extract parts
EXTRACT(YEAR FROM created_at)
EXTRACT(DAYOFWEEK FROM created_at) -- 1=Sunday
-- Format
FORMAT_DATE('%Y-%m-%d', date_column)
FORMAT_TIMESTAMP('%Y-%m-%d %H:%M:%S', ts_column)
String functions:
-- No ILIKE, use LOWER()
LOWER(column) LIKE '%pattern%'
REGEXP_CONTAINS(column, r'pattern')
REGEXP_EXTRACT(column, r'pattern')
-- String manipulation
SPLIT(str, delimiter) -- returns ARRAY
ARRAY_TO_STRING(array, delimiter)
Arrays and structs:
-- Array operations
ARRAY_AGG(column)
UNNEST(array_column)
ARRAY_LENGTH(array_column)
value IN UNNEST(array_column)
-- Struct access
struct_column.field_name
Performance tips:
…
Embed Zoom meeting features into web apps with full or component-based integration.
Build weighted sales forecasts with scenario planning, commit splits, and gap analysis.
Prepare compliant month-end journal entries with debits, credits, and support.
Analyze compensation bands, offer competitiveness, equity grants, and retention risks.
Track hiring stages, update candidate status, and monitor pipeline counts.
Research competitors and compare positioning, messaging, gaps, opportunities, and threats.
Turn data questions into optimized SQL tailored to your database dialect.
Analyze Fabric warehouse performance via CLI and get optimization recommendations.
Run read-only T-SQL queries on Fabric warehouse and lakehouse data.
Query and manage Snowflake databases with natural language and SQL.
Run authoring T-SQL for Fabric warehouses and SQL endpoints from CLI.
Securely query Snowflake warehouses with natural language and retrieve data insights.