| name | postgresql-advanced-queries |
| description | Master advanced PostgreSQL queries - CTEs, window functions, recursive queries |
| version | 3.0.0 |
| sasmp_version | 1.3.0 |
| bonded_agent | 02-postgresql-queries |
| bond_type | PRIMARY_BOND |
| category | database |
| difficulty | intermediate |
| estimated_time | 3h |
PostgreSQL Advanced Queries Skill
Atomic skill for complex query patterns
Overview
Production-ready patterns for CTEs, window functions, recursive queries, and advanced joins.
Prerequisites
- PostgreSQL 16+
- Intermediate SQL knowledge
Parameters
parameters:
query_type:
type: string
required: true
enum: [cte, window, recursive, lateral, aggregate]
tables:
type: array
items: { type: string }
Quick Reference
CTE Pattern
WITH step1 AS (SELECT ...), step2 AS (SELECT ... FROM step1)
SELECT * FROM step2;
Window Functions
ROW_NUMBER() OVER (PARTITION BY cat ORDER BY date DESC)
SUM(amount) OVER (ORDER BY date)
LAG(value, 1) OVER ( )