DB Olympics

Queries · q354 · Head of Merchandising · week 2, night 3

Fennel & Flint and Wiesgrund Wohnen: Historical December Pattern, 2023-2025

“Is the December rating dip a recurring yearly pattern for these two merchants (like we found at Cragsley), or something new and specific to 2025?”

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 SQLViktorOld-school warehouse engineer: explicit JOIN chains straight to the base tables, derived tables, GROUP BY with CASE pivots, few 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 3, request 2 of 3

    Night 2 findings: (1) The shipping-delay hypothesis for the Dec dip holds for Fennel & Flint with a plausible lag — their on-time delivery crashed to 53.7% in November (from ~85-88% normally) and their bad reviews peaked the following month, December (14 reviews, 3.14 avg, 35.7% 1-2 star). But it does NOT explain Wiesgrund Wohnen at all: their delivery performance stayed strong all through Nov-Dec (90.9%, 93.8%) and they used 0% Albion Parcel every single month — yet they had an equally bad December (12 reviews, 3.5 avg, 41.7% 1-2 star). So there are two different causes behind what looked like one 'Home & Living dip,' and I need to find Wiesgrund Wohnen's actual driver. (2) The image-bucket report, run without the active-only filter this time, overturned my 'maybe they're just new/unfinished listings' theory: the 85 zero-image products are actually the OLDEST on average (1,136 days vs ~1,040 for others) and have fewer variants (3.4 vs ~5.5) — these are neglected legacy active listings, not pending-content new ones, and notably zero B2B merchants have any zero-image products (B2B is always at least minimally photographed). So the zero-to-one-image effect looks like a real, if small and old, content gap worth cleaning up, not a proxy for recency. (3) The bundle-user list makes the pattern obvious just from eyeballing the 50 rows: every single bundle-using merchant is in Beauty, Food & Coffee, Books & Stationery, Jewelry, Consumer Electronics, or Home & Living — none are Apparel & Footwear, Sports & Outdoor, or B2B wholesale, and they skew toward low-variant, giftable, small-revenue merchants. I want one clean aggregate to confirm this is a true vertical pattern and not an artifact of which merchants happened to print. Tonight: drill into Wiesgrund Wohnen's actual December driver at the product level, check whether both merchants' December dips are a recurring yearly pattern (like Cragsley's) or unique to 2025, and confirm the bundle-vertical clustering with hard numbers.

    Fennel & Flint and Wiesgrund Wohnen: Historical December Pattern, 2023-2025
    Question
    Is the December rating dip a recurring yearly pattern for these two merchants (like we found at Cragsley), or something new and specific to 2025?
    One row per
    merchant per year, December only, for 2023, 2024, 2025
    Columns
    • merchant_name
    • year
    • dec_review_count
    • dec_avg_rating
    • dec_pct_1_2_star
    • dec_orders_count
  3. Viktor 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 t.name AS merchant_name, y.year,
      COALESCE(r.dec_review_count,0) AS dec_review_count,
      r.dec_avg_rating,
      r.dec_pct_1_2_star,
      COALESCE(o.dec_orders_count,0) AS dec_orders_count
    FROM tenants t
    CROSS JOIN (VALUES (2023),(2024),(2025)) AS y(year)
    LEFT JOIN (
      SELECT tenant_id,
        EXTRACT(YEAR FROM created_at)::int AS yr,
        COUNT(*) AS dec_review_count,
        ROUND(AVG(rating)::numeric,2) AS dec_avg_rating,
        ROUND(100.0*SUM(CASE WHEN rating<=2 THEN 1 ELSE 0 END)/COUNT(*),1) AS dec_pct_1_2_star
      FROM product_reviews
      WHERE is_approved = true AND EXTRACT(MONTH FROM created_at) = 12
      GROUP BY tenant_id, EXTRACT(YEAR FROM created_at)
    ) r ON r.tenant_id = t.id AND r.yr = y.year
    LEFT JOIN (
      SELECT tenant_id,
        EXTRACT(YEAR FROM placed_at)::int AS yr,
        COUNT(*) AS dec_orders_count
      FROM orders
      WHERE status <> 'cancelled' AND EXTRACT(MONTH FROM placed_at) = 12
      GROUP BY tenant_id, EXTRACT(YEAR FROM placed_at)
    ) o ON o.tenant_id = t.id AND o.yr = y.year
    WHERE t.name IN ('Fennel & Flint','Wiesgrund Wohnen')
    ORDER BY t.name, y.year

    “Query compiles cleanly with the expected 6 columns. 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 gives one row per merchant per December (2023–2025) with review count, average rating, % of 1–2 star reviews, and order volume for context — exactly as requested, so Zara can compare each year's December dip across Fennel & Flint and Wiesgrund Wohnen against the Cragsley pattern.”

  4. The report comes back overnight

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

    merchant_name    | year | dec_review_count | dec_avg_rating | dec_pct_1_2_star | dec_orders_count
    -----------------+------+------------------+----------------+------------------+-----------------
    Fennel & Flint   | 2023 |                7 |           4.43 |             14.3 |               28
    Fennel & Flint   | 2024 |                7 |           3.71 |             14.3 |               45
    Fennel & Flint   | 2025 |               14 |           3.14 |             35.7 |               69
    Wiesgrund Wohnen | 2023 |                7 |           4.00 |             28.6 |               29
    Wiesgrund Wohnen | 2024 |                7 |           3.57 |             14.3 |               53
    Wiesgrund Wohnen | 2025 |               12 |           3.50 |             41.7 |               44
    (6 rows)
  5. What came of it

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

    Later queries that build on this report:

    It builds on:

  6. It becomes benchmark query q354

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

    • spellingcast (3×)
    • determinismtie-breaker: tenant names are not unique
    • 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)))
    • made explicita selected t.col gets AS col, its standard name made explicit (3×)
    • 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 t.name AS merchant_name, y.year,SELECT t.name AS merchant_name, y.year AS year,  COALESCE(r.dec_review_count,0) AS dec_review_count,  r.dec_avg_rating,  r.dec_pct_1_2_star,  r.dec_avg_rating AS dec_avg_rating,  r.dec_pct_1_2_star AS dec_pct_1_2_star,  COALESCE(o.dec_orders_count,0) AS dec_orders_countFROM tenants tCROSS JOIN (VALUES (2023),(2024),(2025)) AS y(year)LEFT JOIN (  SELECT tenant_id,    EXTRACT(YEAR FROM created_at)::int AS yr,    CAST(EXTRACT(YEAR FROM created_at) AS int) AS yr,    COUNT(*) AS dec_review_count,    ROUND(AVG(rating)::numeric,2) AS dec_avg_rating,    ROUND(100.0*SUM(CASE WHEN rating<=2 THEN 1 ELSE 0 END)/COUNT(*),1) AS dec_pct_1_2_star    AVG(CAST(rating AS NUMERIC(18,6))) AS dec_avg_rating,    100.0*SUM(CASE WHEN rating<=2 THEN 1 ELSE 0 END)/COUNT(*) AS dec_pct_1_2_star  FROM product_reviews  WHERE is_approved = true AND EXTRACT(MONTH FROM created_at) = 12  GROUP BY tenant_id, EXTRACT(YEAR FROM created_at)) r ON r.tenant_id = t.id AND r.yr = y.yearLEFT JOIN (  SELECT tenant_id,    EXTRACT(YEAR FROM placed_at)::int AS yr,    CAST(EXTRACT(YEAR FROM placed_at) AS int) AS yr,    COUNT(*) AS dec_orders_count  FROM orders  WHERE status <> 'cancelled' AND EXTRACT(MONTH FROM placed_at) = 12  GROUP BY tenant_id, EXTRACT(YEAR FROM placed_at)) o ON o.tenant_id = t.id AND o.yr = y.yearWHERE t.name IN ('Fennel & Flint','Wiesgrund Wohnen')ORDER BY t.name, y.yearORDER BY t.name NULLS LAST, y.year NULLS LAST, t.id NULLS LAST
    SELECT t.name AS merchant_name, y.year AS year,
      COALESCE(r.dec_review_count,0) AS dec_review_count,
      r.dec_avg_rating AS dec_avg_rating,
      r.dec_pct_1_2_star AS dec_pct_1_2_star,
      COALESCE(o.dec_orders_count,0) AS dec_orders_count
    FROM tenants t
    CROSS JOIN (VALUES (2023),(2024),(2025)) AS y(year)
    LEFT JOIN (
      SELECT tenant_id,
        CAST(EXTRACT(YEAR FROM created_at) AS int) AS yr,
        COUNT(*) AS dec_review_count,
        AVG(CAST(rating AS NUMERIC(18,6))) AS dec_avg_rating,
        100.0*SUM(CASE WHEN rating<=2 THEN 1 ELSE 0 END)/COUNT(*) AS dec_pct_1_2_star
      FROM product_reviews
      WHERE is_approved = true AND EXTRACT(MONTH FROM created_at) = 12
      GROUP BY tenant_id, EXTRACT(YEAR FROM created_at)
    ) r ON r.tenant_id = t.id AND r.yr = y.year
    LEFT JOIN (
      SELECT tenant_id,
        CAST(EXTRACT(YEAR FROM placed_at) AS int) AS yr,
        COUNT(*) AS dec_orders_count
      FROM orders
      WHERE status <> 'cancelled' AND EXTRACT(MONTH FROM placed_at) = 12
      GROUP BY tenant_id, EXTRACT(YEAR FROM placed_at)
    ) o ON o.tenant_id = t.id AND o.yr = y.year
    WHERE t.name IN ('Fennel & Flint','Wiesgrund Wohnen')
    ORDER BY t.name NULLS LAST, y.year NULLS LAST, t.id NULLS LAST
    10 ms100 ms1 sHyper14.7 msDuckDB60.2 msGizmoSQL86.5 msclickhouse_brew125 msFirebolt74.8 msDataFusion131 msClickHouse59.0 ms
  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

    Viktor's whole session, 7 turns
    • The request, as Viktor received it
      Report request from Zara Ahmed (analyst for the Head of Merchandising):
      
      Title: Fennel & Flint and Wiesgrund Wohnen: Historical December Pattern, 2023-2025
      Question: Is the December rating dip a recurring yearly pattern for these two merchants (like we found at Cragsley), or something new and specific to 2025?
      Grain: one row per merchant per year, December only, for 2023, 2024, 2025
      Columns:
      - merchant_name
      - year
      - dec_review_count
      - dec_avg_rating
      - dec_pct_1_2_star
      - dec_orders_count
      Details: Filter to tenants named Fennel & Flint and Wiesgrund Wohnen. dec_review_count/dec_avg_rating/dec_pct_1_2_star computed over approved product_reviews with created_at in December of that year (same definitions as prior review-trend reports). dec_orders_count = count of that merchant's orders with placed_at in December of that year and status not cancelled, for volume context. Round avg_rating to 2 decimals, pct to 1 decimal. Order by merchant_name, then year ascending.
      
      Check your query with the warehouse's dry_run tool, then hand it in with submit.
    • Viktor calls dry_run
      SELECT t.name AS merchant_name, y.year,
        COALESCE(r.dec_review_count,0) AS dec_review_count,
        r.dec_avg_rating,
        r.dec_pct_1_2_star,
        COALESCE(o.dec_orders_count,0) AS dec_orders_count
      FROM tenants t
      CROSS JOIN (VALUES (2023),(2024),(2025)) AS y(year)
      LEFT JOIN (
        SELECT tenant_id,
          EXTRACT(YEAR FROM created_at)::int AS yr,
          COUNT(*) AS dec_review_count,
          ROUND(AVG(rating)::numeric,2) AS dec_avg_rating,
          ROUND(100.0*SUM(CASE WHEN rating<=2 THEN 1 ELSE 0 END)/COUNT(*),1) AS dec_pct_1_2_star
        FROM product_reviews
        WHERE is_approved = true AND EXTRACT(MONTH FROM created_at) = 12
        GROUP BY tenant_id, EXTRACT(YEAR FROM created_at)
      ) r ON r.tenant_id = t.id AND r.yr = y.year
      LEFT JOIN (
        SELECT tenant_id,
          EXTRACT(YEAR FROM placed_at)::int AS yr,
          COUNT(*) AS dec_orders_count
        FROM orders
        WHERE status <> 'cancelled' AND EXTRACT(MONTH FROM placed_at) = 12
        GROUP BY tenant_id, EXTRACT(YEAR FROM placed_at)
      ) o ON o.tenant_id = t.id AND o.yr = y.year
      WHERE t.name IN ('Fennel & Flint','Wiesgrund Wohnen')
      ORDER BY t.name, y.year
    • The warehouse answers
      STATUS: COMPILES (dry run on the empty schema, no data read)
      COLUMNS: merchant_name, year, dec_review_count, dec_avg_rating, dec_pct_1_2_star, dec_orders_count
    • ViktorQuery compiles cleanly with the expected 6 columns. Submitting.
    • Viktor calls submit
      SELECT t.name AS merchant_name, y.year,
        COALESCE(r.dec_review_count,0) AS dec_review_count,
        r.dec_avg_rating,
        r.dec_pct_1_2_star,
        COALESCE(o.dec_orders_count,0) AS dec_orders_count
      FROM tenants t
      CROSS JOIN (VALUES (2023),(2024),(2025)) AS y(year)
      LEFT JOIN (
        SELECT tenant_id,
          EXTRACT(YEAR FROM created_at)::int AS yr,
          COUNT(*) AS dec_review_count,
          ROUND(AVG(rating)::numeric,2) AS dec_avg_rating,
          ROUND(100.0*SUM(CASE WHEN rating<=2 THEN 1 ELSE 0 END)/COUNT(*),1) AS dec_pct_1_2_star
        FROM product_reviews
        WHERE is_approved = true AND EXTRACT(MONTH FROM created_at) = 12
        GROUP BY tenant_id, EXTRACT(YEAR FROM created_at)
      ) r ON r.tenant_id = t.id AND r.yr = y.year
      LEFT JOIN (
        SELECT tenant_id,
          EXTRACT(YEAR FROM placed_at)::int AS yr,
          COUNT(*) AS dec_orders_count
        FROM orders
        WHERE status <> 'cancelled' AND EXTRACT(MONTH FROM placed_at) = 12
        GROUP BY tenant_id, EXTRACT(YEAR FROM placed_at)
      ) o ON o.tenant_id = t.id AND o.yr = y.year
      WHERE t.name IN ('Fennel & Flint','Wiesgrund Wohnen')
      ORDER BY t.name, y.year
    • The warehouse answers
      Submitted to tonight's batch. Your work on this request is done.
    • ViktorSubmitted. The report gives one row per merchant per December (2023–2025) with review count, average rating, % of 1–2 star reviews, and order volume for context — exactly as requested, so Zara can compare each year's December dip across Fennel & Flint and Wiesgrund Wohnen against the Cragsley pattern.