Brightlane's pricing team wants to analyse how premium products — those with a list price above $500 — could be positioned across every available category.
Write a query to return each premium product paired with every category, returning the product name, price, and category name.
Assumptions:
- The
productstable contains every product in the catalogue. - The
categoriestable contains every defined category. - The premium condition narrows the result to products with
price > 500before they are paired with categories.
Output:
- One row per premium-product × category combination, with columns
product_name,price, andcategory_name.
Schema · ecommerce 5 tables
Run previews · Check grades
Write a query, then run it to see results here.
Worked solution Try it yourself first
SELECT
p.name AS product_name,
p.price,
c.name AS category_name
FROM
products p
CROSS JOIN categories c
WHERE
p.price > 500 The shape
WHERE p.price > 500 narrows products to the premium cohort, and CROSS JOIN categories c expands each premium product across every category — including the category it currently sits in. The output carries three columns: the product name, its price (for the pricing team to see directly), and the candidate category.
Clause by clause
FROM products p CROSS JOIN categories cis the unconditional pairing. Every row inproductscombines with every row incategories.WHERE p.price > 500filters the left side to products whose list price exceeds $500. The comparison is strict — a product at exactly500does not pass. Premium, by the pricing team's working definition, sits above that threshold.p.name AS product_nameandp.priceread two columns from the products side. Thepricecolumn doesn't need an alias because it's already named appropriately; PostgreSQL will return it asprice.c.name AS category_namereads the candidate category from the right side. The aliascdisambiguates thisnamecolumn from the product'snamecolumn on the left.
Why include price in the output
The team is analysing positioning. Seeing each pairing alongside its price keeps the analysis self-contained — the reader doesn't have to cross-reference back to the product table to know which premium tier a given pairing represents. A $1,199 product positioned in Home Goods reads differently from a $549 product positioned in the same category. Carrying the price through makes that visible in the result without a second query.
You practiced CROSS JOIN against a price-filtered cohort. The premium-positioning use case is the everyday version of "hypothetical placement," where the cross-product is the answer because no actual relationship has been decided yet.