DB Olympics

Queries · q358 · Head of Merchandising · week 2, night 4

Fennel & Flint December 2025: Product-Level Review Breakdown

“Is Fennel & Flint's declining rating trend concentrated in specific products, or spread broadly across its catalog, in parallel to what we found at Wiesgrund Wohnen?”

Manager · asked the questionFreya LindgrenHead of Merchandising. Came from a fashion marketplace's catalog team. Responsible for helping merchants present their products well.
Analyst · planned the reportZara AhmedExploratory: looks at the raw detail of an unfamiliar area before aggregating it.
Engineer · wrote the SQLFelixJunior engineer who nests subqueries in FROM and WHERE (IN, EXISTS, correlated subqueries) rather than CTEs.

Fictional people at a fictional company, each played by a language-model agent. Who they are and what they are told

  1. Freya Lindgren writes to Zara Ahmed

    The manager, at the start of week 2

    Subject: Good start — let's dig into the risk areas

    Hi Zara,

    This is really useful, and a few things jumped out that I want to understand better before Friday.

    The Cragsley Outfitters finding worries me most — our #2 merchant by revenue with real quality concentration, and some of those poorly-rated items are still selling briskly. That combination (strong sales, weak ratings, sizable product count) feels like the kind of thing that erodes trust quietly until it doesn't. I'd like to understand it better: is this concentrated in certain kinds of products, has it been building over time, and does it look like it's about to hit sales or is demand just lagging behind reputation?

    Second, the December rating dip needs a clearer story. You flagged it as needing a second month to confirm — I agree, but I'd also like to understand whether there's something explainable behind it (seasonal returns, a particular product push, shipping delays around the holidays) rather than just watching and waiting. If Fennel & Flint and Wiesgrund Wohnen are worth a check-in, I want to go into that conversation knowing roughly what happened.

    Third, I was surprised that going from zero to one image makes such a big difference but more images after that don't. Before I turn that into a merchant talking point, I want to know if we're actually looking at a real presentation effect or just a stand-in for something else — are the zero-image listings systematically different in some way, like older, or a different kind of product?

    Finally, on bundles: you said it's white space but we can't test performance yet because usage is too rare. I'd like to understand it a bit more anecdotally before we design a pilot — among the handful of merchants that do use bundles, is there anything that distinguishes them, even descriptively, from the ones that don't?

    Thanks again — this is exactly the kind of clarity I needed.

    Freya

  2. Zara Ahmed plans the night

    The analyst · week 2, night 4, request 3 of 3

    Night 3 findings: (1) Wiesgrund Wohnen's December reviews are scattered thinly across 10 different products (mostly 1 review each) rather than concentrated on one bad item — but nearly all of them are fragile homeware: vases, a frying pan, dinner plates, a casserole dish, glassware. That points away from 'systemic quality problem' and toward 'breakage in transit,' which wouldn't show up in on-time-delivery stats (an item can arrive on schedule but shattered). (2) The 3-year December history splits the two merchants clearly: Fennel & Flint shows a real, monotonic 3-year rating decline (4.43 → 3.71 → 3.14) alongside order growth (28 → 45 → 69), consistent with a merchant whose quality control hasn't kept pace with scale; Wiesgrund Wohnen's history is noisier and non-monotonic (4.00 → 3.57 → 3.50, with 2023 already at 28.6% 1-2-star on a tiny sample), more consistent with episodic bad luck than a trend. (3) The bundle-by-vertical split is suspiciously clean — exactly 100% of merchants in six verticals (Beauty, Books & Stationery, Consumer Electronics, Food & Coffee, Home & Living, Jewelry) have made at least one bundle, and exactly 0% in the other five (Apparel & Footwear, both B2B verticals, Pet Supplies, Sports & Outdoor) have made any. A binary split with no partial adoption anywhere is unusual for organic merchant behavior and makes me suspect this may reflect how bundles were seeded/templated per vertical rather than a genuine merchandising choice — I want to check the creation-date distribution before I tell Freya it's a real behavioral pattern. For this final night: (A) check whether bundle creation clusters in one burst (seeding) or spreads out over time (organic), (B) test the fragile-goods-breakage theory with actual return/damage data across Home & Living, and (C) run the same product-level breakdown for Fennel & Flint's December reviews that we did for Wiesgrund, to see if their decline is broad-based or concentrated.

    Fennel & Flint December 2025: Product-Level Review Breakdown
    Question
    Is Fennel & Flint's declining rating trend concentrated in specific products, or spread broadly across its catalog, in parallel to what we found at Wiesgrund Wohnen?
    One row per
    product, for Fennel & Flint only, among products with at least one approved review created in December 2025
    Columns
    • product_name
    • category_name
    • review_count
    • avg_rating
    • pct_1_2_star
    • units_sold_last_12mo
  3. Felix writes the SQL

    The engineer · 1 dry run on the empty schema, then the submission

    Dry run 1 · STATUS: COMPILES (dry run on the empty schema, no data read)
    SELECT
      p.name AS product_name,
      c.name AS category_name,
      (SELECT COUNT(*) FROM product_reviews pr
         WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
           AND pr.is_approved = true
           AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
      ) AS review_count,
      (SELECT ROUND(AVG(pr.rating)::numeric, 2) FROM product_reviews pr
         WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
           AND pr.is_approved = true
           AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
      ) AS avg_rating,
      (SELECT ROUND(100.0 * SUM(CASE WHEN pr.rating <= 2 THEN 1 ELSE 0 END) / COUNT(*), 1) FROM product_reviews pr
         WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
           AND pr.is_approved = true
           AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
      ) AS pct_1_2_star,
      (SELECT COALESCE(SUM(oi.quantity), 0)
         FROM order_items oi
         JOIN orders o ON o.id = oi.order_id
         WHERE oi.tenant_id = p.tenant_id
           AND o.tenant_id = p.tenant_id
           AND o.status != 'cancelled'
           AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01'
           AND oi.product_variant_id IN (SELECT pv.id FROM product_variants pv WHERE pv.product_id = p.id)
      ) AS units_sold_last_12mo
    FROM products p
    LEFT JOIN categories c ON c.id = p.primary_category_id
    WHERE p.tenant_id = (SELECT t.id FROM tenants t WHERE t.name = 'Fennel & Flint')
      AND EXISTS (
        SELECT 1 FROM product_reviews pr
        WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
          AND pr.is_approved = true
          AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
      )
    ORDER BY review_count DESC, avg_rating ASC

    “Query compiles cleanly. Submitting.”

    Submitted · the SQL of the last dry run, unchanged · Submitted to tonight's batch. Your work on this request is done.

    “Submitted. The report returns one row per Fennel & Flint product with at least one approved December 2025 review, showing product name, category, review count, average rating, share of 1–2 star reviews, and units sold in 2025 (non-cancelled orders), ordered by review count descending then average rating ascending — matching the grain and definitions used in the Wiesgrund Wohnen report.”

  4. The report comes back overnight

    As Zara Ahmed saw it, from the small dataset the agents worked on

    product_name                             | category_name | review_count | avg_rating | pct_1_2_star | units_sold_last_12mo
    -----------------------------------------+---------------+--------------+------------+--------------+---------------------
    Sea Salt Candle                          | Decor         |            1 |       1.00 |        100.0 |                    6
    Washed Organic Cotton Duvet Cover        | Bedding       |            1 |       1.00 |        100.0 |                   27
    Fluted Recycled Glass Vase               | Decor         |            1 |       1.00 |        100.0 |                   10
    Reactive Glaze Set of 4 Dinner Plate Set | Tableware     |            1 |       1.00 |        100.0 |                   10
    Retro Kettle                             | Appliances    |            1 |       2.00 |        100.0 |                    3
    Cedar & Smoke Candle                     | Decor         |            1 |       3.00 |          0.0 |                   14
    Fringed Throw                            | Textiles      |            1 |       3.00 |          0.0 |                   19
    Round 24cm Enamelled Cast Iron Casserole | Cookware      |            1 |       3.00 |          0.0 |                    4
    Carbon Steel 26cm Frying Pan             | Cookware      |            1 |       4.00 |          0.0 |                   27
    Santoku 18cm Chef's Knife                | Cookware      |            1 |       5.00 |          0.0 |                    3
    Plush Organic Cotton Bath Towel          | Towels        |            1 |       5.00 |          0.0 |                   13
    Tumblers Set of 4 Glassware Set          | Glassware     |            1 |       5.00 |          0.0 |                   26
    Round 24cm Cast Iron Casserole Dish      | Cookware      |            1 |       5.00 |          0.0 |                    6
    Percale Organic Cotton Duvet Cover       | Bedding       |            1 |       5.00 |          0.0 |                    5
    (14 rows)
  5. What came of it

    The memo and the queries that followed; links found by title, so inferred

    It builds on:

  6. It becomes benchmark query q358

    Changed only where the benchmark needs the same result on every system

    • spellingcast
    • determinismtie-breaker: products primary key
    • numericsdocs/NUMERICS.md: rounding removed; results keep full precision; bare NUMERIC cast that only served the rounding removed; AVG over an integer computed as a decimal: AVG(CAST(x AS NUMERIC(18,6)))
    • numericsdocs/NUMERICS.md: rounding removed; results keep full precision
    • made explicita selected t.col gets AS col, its standard name made explicit
    • determinismthe standard leaves the place of NULLs in a sort to the implementation: NULLS LAST ascending, NULLS FIRST descending, as in the reference results (3×)
    The benchmark text, against the submitted SQL
    SELECT  p.name AS product_name,  c.name AS category_name,  (SELECT COUNT(*) FROM product_reviews pr     WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id       AND pr.is_approved = true       AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'  ) AS review_count,  (SELECT ROUND(AVG(pr.rating)::numeric, 2) FROM product_reviews pr  (SELECT AVG(CAST(pr.rating AS NUMERIC(18,6))) FROM product_reviews pr     WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id       AND pr.is_approved = true       AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'  ) AS avg_rating,  (SELECT ROUND(100.0 * SUM(CASE WHEN pr.rating <= 2 THEN 1 ELSE 0 END) / COUNT(*), 1) FROM product_reviews pr  (SELECT 100.0 * SUM(CASE WHEN pr.rating <= 2 THEN 1 ELSE 0 END) / COUNT(*) FROM product_reviews pr     WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id       AND pr.is_approved = true       AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'  ) AS pct_1_2_star,  (SELECT COALESCE(SUM(oi.quantity), 0)     FROM order_items oi     JOIN orders o ON o.id = oi.order_id     WHERE oi.tenant_id = p.tenant_id       AND o.tenant_id = p.tenant_id       AND o.status != 'cancelled'       AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01'       AND oi.product_variant_id IN (SELECT pv.id FROM product_variants pv WHERE pv.product_id = p.id)  ) AS units_sold_last_12moFROM products pLEFT JOIN categories c ON c.id = p.primary_category_idWHERE p.tenant_id = (SELECT t.id FROM tenants t WHERE t.name = 'Fennel & Flint')WHERE p.tenant_id = (SELECT t.id AS id FROM tenants t WHERE t.name = 'Fennel & Flint')  AND EXISTS (    SELECT 1 FROM product_reviews pr    WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id      AND pr.is_approved = true      AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'  )ORDER BY review_count DESC, avg_rating ASCORDER BY review_count DESC NULLS FIRST, avg_rating ASC NULLS LAST, p.id ASC NULLS LAST
    SELECT
      p.name AS product_name,
      c.name AS category_name,
      (SELECT COUNT(*) FROM product_reviews pr
         WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
           AND pr.is_approved = true
           AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
      ) AS review_count,
      (SELECT AVG(CAST(pr.rating AS NUMERIC(18,6))) FROM product_reviews pr
         WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
           AND pr.is_approved = true
           AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
      ) AS avg_rating,
      (SELECT 100.0 * SUM(CASE WHEN pr.rating <= 2 THEN 1 ELSE 0 END) / COUNT(*) FROM product_reviews pr
         WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
           AND pr.is_approved = true
           AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
      ) AS pct_1_2_star,
      (SELECT COALESCE(SUM(oi.quantity), 0)
         FROM order_items oi
         JOIN orders o ON o.id = oi.order_id
         WHERE oi.tenant_id = p.tenant_id
           AND o.tenant_id = p.tenant_id
           AND o.status != 'cancelled'
           AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01'
           AND oi.product_variant_id IN (SELECT pv.id FROM product_variants pv WHERE pv.product_id = p.id)
      ) AS units_sold_last_12mo
    FROM products p
    LEFT JOIN categories c ON c.id = p.primary_category_id
    WHERE p.tenant_id = (SELECT t.id AS id FROM tenants t WHERE t.name = 'Fennel & Flint')
      AND EXISTS (
        SELECT 1 FROM product_reviews pr
        WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
          AND pr.is_approved = true
          AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
      )
    ORDER BY review_count DESC NULLS FIRST, avg_rating ASC NULLS LAST, p.id ASC NULLS LAST
    100 ms1 s10 s100 sHyper361 msDuckDB12.7 sGizmoSQL11.0 sclickhouse_brew438 msFirebolt379 msDataFusionerrorClickHouseerror
    • DataFusionSchema error: No field named p.id.
    • ClickHouseCode: 48. DB::Exception: Correlated subqueries are not supported as IN function arguments yet, but found in expression: oi.product_variant_id IN (SELECT pv.id FROM product_variants AS pv WHERE pv.product_id = p.id). (NOT_IMPLEMENTED)
  7. Everything, as recorded

    The agents' own records, as the role play wrote them; only the personal data of the person who ran it is redacted

    Felix's whole session, 7 turns
    • The request, as Felix received it
      Report request from Zara Ahmed (analyst for the Head of Merchandising):
      
      Title: Fennel & Flint December 2025: Product-Level Review Breakdown
      Question: Is Fennel & Flint's declining rating trend concentrated in specific products, or spread broadly across its catalog, in parallel to what we found at Wiesgrund Wohnen?
      Grain: one row per product, for Fennel & Flint only, among products with at least one approved review created in December 2025
      Columns:
      - product_name
      - category_name
      - review_count
      - avg_rating
      - pct_1_2_star
      - units_sold_last_12mo
      Details: Same definitions as the Wiesgrund Wohnen December 2025: Product-Level Review Breakdown report, filtered to tenant = Fennel & Flint instead: review_count/avg_rating/pct_1_2_star over approved product_reviews with created_at in December 2025, category_name from primary_category_id, units_sold_last_12mo from order_items/orders placed in 2025 with status not cancelled. Round avg_rating to 2 decimals, pct to 1 decimal. Order by review_count descending, tie-break by avg_rating ascending.
      
      Check your query with the warehouse's dry_run tool, then hand it in with submit.
    • Felix calls dry_run
      SELECT
        p.name AS product_name,
        c.name AS category_name,
        (SELECT COUNT(*) FROM product_reviews pr
           WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
             AND pr.is_approved = true
             AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
        ) AS review_count,
        (SELECT ROUND(AVG(pr.rating)::numeric, 2) FROM product_reviews pr
           WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
             AND pr.is_approved = true
             AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
        ) AS avg_rating,
        (SELECT ROUND(100.0 * SUM(CASE WHEN pr.rating <= 2 THEN 1 ELSE 0 END) / COUNT(*), 1) FROM product_reviews pr
           WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
             AND pr.is_approved = true
             AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
        ) AS pct_1_2_star,
        (SELECT COALESCE(SUM(oi.quantity), 0)
           FROM order_items oi
           JOIN orders o ON o.id = oi.order_id
           WHERE oi.tenant_id = p.tenant_id
             AND o.tenant_id = p.tenant_id
             AND o.status != 'cancelled'
             AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01'
             AND oi.product_variant_id IN (SELECT pv.id FROM product_variants pv WHERE pv.product_id = p.id)
        ) AS units_sold_last_12mo
      FROM products p
      LEFT JOIN categories c ON c.id = p.primary_category_id
      WHERE p.tenant_id = (SELECT t.id FROM tenants t WHERE t.name = 'Fennel & Flint')
        AND EXISTS (
          SELECT 1 FROM product_reviews pr
          WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
            AND pr.is_approved = true
            AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
        )
      ORDER BY review_count DESC, avg_rating ASC
    • The warehouse answers
      STATUS: COMPILES (dry run on the empty schema, no data read)
      COLUMNS: product_name, category_name, review_count, avg_rating, pct_1_2_star, units_sold_last_12mo
    • FelixQuery compiles cleanly. Submitting.
    • Felix calls submit
      SELECT
        p.name AS product_name,
        c.name AS category_name,
        (SELECT COUNT(*) FROM product_reviews pr
           WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
             AND pr.is_approved = true
             AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
        ) AS review_count,
        (SELECT ROUND(AVG(pr.rating)::numeric, 2) FROM product_reviews pr
           WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
             AND pr.is_approved = true
             AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
        ) AS avg_rating,
        (SELECT ROUND(100.0 * SUM(CASE WHEN pr.rating <= 2 THEN 1 ELSE 0 END) / COUNT(*), 1) FROM product_reviews pr
           WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
             AND pr.is_approved = true
             AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
        ) AS pct_1_2_star,
        (SELECT COALESCE(SUM(oi.quantity), 0)
           FROM order_items oi
           JOIN orders o ON o.id = oi.order_id
           WHERE oi.tenant_id = p.tenant_id
             AND o.tenant_id = p.tenant_id
             AND o.status != 'cancelled'
             AND o.placed_at >= DATE '2025-01-01' AND o.placed_at < DATE '2026-01-01'
             AND oi.product_variant_id IN (SELECT pv.id FROM product_variants pv WHERE pv.product_id = p.id)
        ) AS units_sold_last_12mo
      FROM products p
      LEFT JOIN categories c ON c.id = p.primary_category_id
      WHERE p.tenant_id = (SELECT t.id FROM tenants t WHERE t.name = 'Fennel & Flint')
        AND EXISTS (
          SELECT 1 FROM product_reviews pr
          WHERE pr.product_id = p.id AND pr.tenant_id = p.tenant_id
            AND pr.is_approved = true
            AND pr.created_at >= DATE '2025-12-01' AND pr.created_at < DATE '2026-01-01'
        )
      ORDER BY review_count DESC, avg_rating ASC
    • The warehouse answers
      Submitted to tonight's batch. Your work on this request is done.
    • FelixSubmitted. The report returns one row per Fennel & Flint product with at least one approved December 2025 review, showing product name, category, review count, average rating, share of 1–2 star reviews, and units sold in 2025 (non-cancelled orders), ordered by review count descending then average rating ascending — matching the grain and definitions used in the Wiesgrund Wohnen report.