sql-queries

Generate SQL queries across PostgreSQL, Snowflake, BigQuery, Redshift, and Databricks SQL.

Updated Feb 6, 2026
One-click install
npx skills add https://github.com/lohasle/knowledge-work-plugins --skill sql-queries-lohasle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sql-queries
Source: https://github.com/lohasle/knowledge-work-plugins/tree/main/data/skills/sql-queries
Command: npx skills add https://github.com/lohasle/knowledge-work-plugins --skill sql-queries-lohasle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps users write correct, performant, and readable SQL queries across various major data warehouse dialects, simplifying complex data analysis and optimization tasks.

Core Features & Use Cases

  • Cross-Dialect Support: Provides syntax and performance tips for PostgreSQL, Snowflake, BigQuery, Redshift, and Databricks SQL.
  • Advanced Patterns: Demonstrates common SQL patterns like window functions, CTEs, cohort retention, funnel analysis, and deduplication.
  • Debugging Guidance: Offers practical advice for troubleshooting common SQL errors.
  • Use Case: Optimize a slow-running Snowflake query by applying dialect-specific performance tips and refactoring with CTEs for better readability.

Quick Start

Use the sql-queries skill to write a PostgreSQL query that calculates the 7-day moving average of daily revenue.

Frequently Asked Questions about sql-queries

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a SQL query for cohort retention analysis that works across BigQuery and Snowflake?

SQL cohort retention queries use CTEs to group users by signup date and window functions to calculate retention rates. This Skill generates cross-dialect SQL for BigQuery and Snowflake, adapting syntax differences while producing correct retention analytics.

What is the best way to optimize a slow Snowflake query using CTEs?

Optimizing a slow Snowflake query involves refactoring nested subqueries into readable CTEs and applying dialect-specific performance tips. This Skill provides targeted guidance to restructure queries for better execution efficiency.

Can I use window functions for funnel analysis in PostgreSQL and Redshift?

Window functions enable funnel analysis in PostgreSQL and Redshift by tracking user progression through event stages. This Skill generates correct syntax for both dialects, ensuring accurate funnel step tracking and user deduplication.

How do I troubleshoot common SQL errors when writing deduplication queries in Databricks SQL?

Troubleshooting SQL deduplication errors in Databricks SQL often requires checking partition logic in window functions. This Skill provides debugging guidance for common errors, ensuring correct row ranking and duplicate removal.

Does this SQL query generator support calculating a 7-day moving average in PostgreSQL?

Yes, calculating a 7-day moving average in PostgreSQL is supported using window functions with frame specifications. This Skill generates performant PostgreSQL queries for daily revenue moving averages with correct syntax.