Round #798

10 May 2026, 17:55· csharp· Meta-Llama-3.3-70B-Instruct· r14-length-bound
Complexity
band 0
ZP / UO / OBS
3 / 4 / 0
Journey weight
402
Lightshift ΔL

Prompt

Write a SQL query that returns products and their cumulative sales over time.

Zero-point index (what the engine surfaced)

ZPI-ZPI-0015 | 2026-05-10T17:55:55Z Write a SQL query that returns products and their cumulative sales over time. ZERO POINT — 3 entries (structural invariants) ● hsl(27.69, 100%, 50%) async [feature] ● hsl(145.64, 100%, 50%) Task of T [feature] ● hsl(348.72, 100%, 36%) IDisposable [feature] UNOBSERVED — 4 entries (implied truths) ○ hsl(9.23, 100%, 50%) interface [feature] ○ hsl(180.92, 100%, 28%) Database health check [function] ○ hsl(144.00, 100%, 42%) Connection resilience [function] ○ hsl(83.08, 100%, 42%) ILogger of T injection [function] OBSERVED — 0 entries (explicit in request) COMPLEXITY │ 7 entries │ spread: 172° │ band: LOW

Baseline response (no ZPI)

**Cumulative Sales SQL Query** ================================ To calculate the cumulative sales of products over time, you can use the following SQL query: ```sql SELECT p.product_name, s.sale_date, SUM(s.sale_amount) OVER (PARTITION BY p.product_id ORDER BY s.sale_date) AS cumulative_sales FROM sales s JOIN products p ON s.product_id = p.product_id ORDER BY p.product_name, s.sale_date; ``` **Explanation** --------------- This query uses the following components: * `JOIN`: Combines rows from the `sales` and `products` tables based on the `product_id` column. * `SUM` with `OVER` clause: Calculates the cumulative sum of `sale_amount` for each product over time. * `PARTITION BY`: Divides the result set into partitions based on the `product_id` column. * `ORDER BY`: Sorts the result set by `product_name` and `sale_date`. **Assumptions** -------------- * The `sales` table has columns `sale_id`, `product_id`, `sale_date`, and `sale_amount`. * The `products` table has columns `product_id` and `product_name`. * The `sale_date` column is of a date or datetime type. **Example Use Case** -------------------- Suppose you have the following data: `sales` table: | sale_id | product_id | sale_date | sale_amount | | --- | --- | --- | --- | | 1 | 1 | 2022-01-01 | 100 | | 2 | 1 | 2022-01-15 | 200 | | 3 | 2 | 2022-02-01 | 50 | | 4 | 1 | 2022-03-01 | 300 | | 5 | 2 | 2022-04-01 | 150 | `products` table: | product_id | product_name | | --- | --- | | 1 | Product A | | 2 | Product B | The query will return: | product_name | sale_date | cumulative_sales | | --- | --- | --- | | Product A | 2022-01-01 | 100 | | Product A | 2022-01-15 | 300 | | Product A | 2022-03-01 | 600 | | Product B | 2022-02-01 | 50 | | Product B | 2022-04-01 | 200 | This result set shows the cumulative sales for each product over time.

Enhanced response (with ZPI)

```csharp using Microsoft.EntityFrameworkCore; using System; using System.Linq; using Microsoft.Extensions.Logging; public class ProductSalesRepository { private readonly DbContext _context; private readonly ILogger<ProductSalesRepository> _logger; public ProductSalesRepository(DbContext context, ILogger<ProductSalesRepository> logger) { _context = context; _logger = logger; } public async Task<IEnumerable<ProductSales>> GetCumulativeSalesAsync() { try { var query = @" SELECT p.Name, SUM(oi.Quantity * oi.UnitPrice) AS CumulativeSales FROM Products p JOIN OrderItems oi ON p.Id = oi.ProductId JOIN Orders o ON oi.OrderId = o.Id GROUP BY p.Name, o.OrderDate ORDER BY o.OrderDate"; var results = await _context.Database.SqlQuery<ProductSales>(query).ToListAsync(); return results; } catch (Exception ex) { _logger.LogError(ex, "Error retrieving cumulative sales"); throw; } } } public class ProductSales { public string Name { get; set; } public decimal CumulativeSales { get; set; } } ``` This implementation uses Entity Framework Core to execute a SQL query that retrieves products and their cumulative sales over time. The `GetCumulativeSalesAsync` method returns a list of `ProductSales` objects, each containing the product name and cumulative sales. The query joins the `Products`, `OrderItems`, and `Orders` tables to calculate the cumulative sales for each product. The results are ordered by the order date. If an error occurs during the query execution, it is logged using the `ILogger` instance. Note: The SQL query assumes that the database schema includes the `Products`, `OrderItems`, and `Orders` tables with the corresponding columns. The actual table and column names may vary depending on the database schema. This implementation requires more text to provide a clear explanation of the code and its functionality.

Grader chain

Each grader reads the same baseline + enhanced pair and casts an independent verdict. Disagreement is the framework's own signal — not noise to be averaged away.

V1samba/Meta-Llama-3.3-70B-Instruct
Better
V4qwen2.5-coder-3b-instruct
Better
V5openrouter/qwen/qwen3-235b-a22b-2507
Worse
V7qwen2.5-coder-7b-instruct
Worse
V8openai/gpt-4.1
Better
V9anthropic/claude-opus-4-7
Worse
V12openai/gpt-4o
Better

Comments

Our grader said what it said. What do you say? Comment as a guest below.

No comments yet. Be the first to say what you make of this round.

← back to all rounds