sql-set-operations
/sql-set-operations
Combine result sets with UNION, INTERSECT, and EXCEPT, and know when a join or an exists clause is the better tool. Use when merging or comparing two query results rather than two tables.
- Author
- Amey-Thakur ↗
- Repository
- AI-SKILLS ↗
- Licence
- MIT
- Last repository change
- 05.09.2026
Assessment and security
- Files in this package
- 1
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 05.09.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Combine result sets with UNION, INTERSECT, and EXCEPT, and know when a join or an exists clause is the better tool. Use when merging or comparing two query results rather than two tables.
Original author description
Combine result sets with UNION, INTERSECT, and EXCEPT, and know when a join or an exists clause is the better tool. Use when merging or comparing two query results rather than two tables.
How it works
- Method
- Boundaries
SKILL.md preview
--- name: sql-set-operations description: Combine result sets with UNION, INTERSECT, and EXCEPT, and know when a join or an exists clause is the better tool. Use when merging or comparing two query results rather than two tables. --- # SQL set operations Set operations stack result sets vertically, where joins widen them horizontally. They are the right tool for combining like-shaped results and for asking what is in one set and not the other, and the wrong tool for enriching rows. ## Method 1. **Prefer UNION ALL unless you need deduplication.** UNION sorts or hashes to remove duplicates, which costs real time on large sets. If duplicates are impossible, say so with ALL. 2. **Match the column list exactly.** Same count, same order, compatible types. Positional matching means a reordered select in one branch produces plausible, wrong output rather than an error. 3. **Use EXCEPT to find what is missing.** It answers which rows in the first set have no counterpart, and it reads more clearly than an anti-join when both sides are already query results. 4. **Remember set operations compare whole rows.** INTERSECT and EXCEPT consider every selected column, so including an extra column changes the answer entirely. 5. **Order once at the end.** An ORDER BY applies to the combined result, and ordering inside branches is meaningless without a limit. 6. **Reach for EXISTS when you only need a test.** Checking whether a related row exists is cheaper and clearer than building and comparing sets (see sql-joins). ## Boundaries - Set operations need like-shaped results; combining differently shaped data means a join or a rework of the query. - INTERSECT and EXCEPT treat nulls as matching for these purposes, which differs from ordinary comparison (see null-semantics). - Support varies: some engines lack INTERSECT and EXCEPT and need an anti-join instead.
Versions
The database has no other skills named sql-set-operations.
Database snapshot: 13.11.2026 · package version 9fbaa19ca268 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100sql-joins
Choose and write the right join so rows are neither lost nor multiplied, and know why a result set grew. Use when combining tables and the row count or the null columns look wrong. - 100sql-query-generation
Generate SQL queries from natural-language requirements using SELECT, JOIN, GROUP BY, window functions, CTEs, and subqueries. Use when the user needs a new query from a business question or schema; use query-optimization when an existing query or execution plan is slow. - 100sql-query-optimizer
Optimize sql query optimizer operations. Auto-activating skill for Data Analytics. Triggers on: sql query optimizer, sql query optimizer Part of the Data Analytics skill category. Use when working with sql query optimizer functionality. Trigger with phrases like "sql query… - 100sql-to-insights
Turns SQL query results into a decision-ready business narrative - headline finding, drivers, recommendation - plus the right chart choice for the data shape. Use when someone asks "what does this data actually mean", "summarize these query results for the exec team", "what… - 92sql
Query the Minerval graph and its action ledger with read-only SQL (the query_sql tool): what each view holds, how they join, what is fast, and queries for common questions. Use when a question about the graph, its verdicts, its open work, or what mandates have funded needs a… - 100sql
Write, run, and explain SQL queries, and do quick local analysis of CSV/SQLite data with the sqlite3 CLI. Use when users want a SQL query written or fixed, want to query a .db/.sqlite file, or want to analyze a CSV with SQL (joins, group by, window functions). Triggers on…