Back to Practice
#0347

All Product Color Combinations

EasySQL15 min10 XP

Problem

Return product and color for every product-color combination.

Why This Matters

SQL interviews usually test whether you can turn a business question into the right rows, grouping level, join type, and edge-case behavior.

Schema

products(product TEXT); colors(color TEXT)

Examples

Example 1
Input2 products and 2 colors
Output4 combinations

CROSS JOIN creates the Cartesian product.

Constraints

  • Return only the requested columns.
  • Use deterministic ORDER BY when multiple rows are returned.
  • Assume SQLite-compatible SQL unless the prompt states otherwise.
CodeSQL
Visible browser tests run here when available.
Testcases1 visible / 3 hidden categories
Core SQL case
Input2 products and 2 colors
Expected[["Hat","Blue"],["Hat","Red"],["Shirt","Blue"],["Shirt","Red"]]

CROSS JOIN creates the Cartesian product.

Hidden Test Categories
Empty or missing matchesDuplicate rows or tiesNULL values where the pattern commonly breaks