Practice Free
EasyFundamentals

Product Catalog Wildcard Pattern Search

Frequently Asked By:AppleGoogleAmazon
Interactive In-Browser Workspace

Practice this problem on live schema tables in PostgreSQL 16 WASM with instant row verification and visual EXPLAIN plans.

Solve in Workbench

Problem Statement

Query the `products` table to find items where: - `category` equals `'Audio'` - `product_title` contains either `'Wireless'` or `'Bluetooth'` (using the SQL `LIKE` operator) - `retail_price` is strictly less than **100.00** Return: 1. `sku` 2. `product_title` 3. `retail_price` 4. `in_stock` Order the result by `retail_price` ascending, breaking ties by `sku` ascending.

Why Technical Interviewers Ask This

The merchandising team is running a summer electronics promo. They need to locate all audio accessories whose product title contains the keyword 'Wireless' or 'Bluetooth' and whose retail price is under $100.

Common Pitfalls & Interview Traps

Forgetting required sorting and deterministic tie-breaking.
Not accounting for NULL or zero-value denominators during calculations.
Using inefficient quadratic subqueries instead of single-pass fundamentals constructs.

Canonical Modern SQL Solution

PostgreSQL 16 / ANSI SQL
SELECT 
        sku,
        product_title,
        retail_price,
        in_stock
      FROM products
      WHERE category = 'Audio'
        AND (product_title LIKE '%Wireless%' OR product_title LIKE '%Bluetooth%')
        AND retail_price < 100.00
      ORDER BY retail_price ASC, sku ASC;
Approach Breakdown
This query addresses the problem requirements by filtering and structuring data in Fundamentals. It meets the target criteria: Budget wireless and Bluetooth audio products sorted by price ascending.

Edge Cases to Verbally Clarify with Your Interviewer

The dataset contains zero matching records (must return valid empty result without crashing).
Multiple records tie on sorting criteria (must evaluate tie-breaking order deterministically).
Foreign keys or secondary attributes have NULL values.

Frequently Asked Follow-Up Questions

What makes this question a favorite among Apple and Google interviewers?

Interviewers use this problem to test whether candidates write defensive, scalable Fundamentals queries that run efficiently on multi-million row production databases without excessive memory usage.

How does the query optimizer execute this query?

Using single-pass table scans with index lookups or sort buffers. Running EXPLAIN (ANALYZE, BUFFERS) in the DB Exercises workbench visualizes the execution nodes and buffer hit cache.

More FAANG SQL Interview Questions

View all questions