STOCKROOMDC-04 · Inventory Control
--:--:--
Live stock wire
Total inventory value · at sell price
$0
AT COST $0 POTENTIAL MARGIN 0% UNITS ON HAND 0 ACTIVE SKUS 0
30-DAY VALUE TRACE · reconstructed from stock_movements
Units on hand
0u
Below reorder point
0SKUs
Movements · last 30 d
0tx

Low stock — action queue

0

Query-driven analytics

Every panel below is the result set of a literal SQL statement executed by the in-browser engine against products ⋈ stock_movements. Edit a query in the SQL console and the analytics follow.

4 REGISTERED QUERIES · ENGINE v1.2

Product master

Filter by category, status or free text. Stock levels are maintained exclusively through logged movements — direct edits are written as adjustment transactions.

/ search · N new SKU

Stock movement ledger

Every receipt, issue and count correction lands here. The ledger feeds the low-stock alerts, the 30-day history query and the top-sellers ranking.

M log movement

Log movement

INSERT INTO stock_movements
—
Signed quantity is applied to products.current_stock immediately; all four analytics queries re-execute.

Ledger

SQL console

A working SELECT engine: SELECT · FROM · JOIN…ON · WHERE · GROUP BY · HAVING · ORDER BY · LIMIT, aggregates (SUM/COUNT/AVG/MIN/MAX), arithmetic, DATE_SUB(NOW(), INTERVAL n DAY), LIKE, IN and BETWEEN.

mysql · dc04_inventory · session active—
tables: products · stock_movements

Schema

Result set

no query executed
Result grid will render here. Try one of the registered queries.

Schema, query contract & docs

The four required analytics queries are registered below exactly as specified, executed by the engine on every data change.

DDL — source of truth


      

Relationships & integrity

stock_movements.product_id → products.product_id (many-to-one). All JOINs in Q3/Q4 use this key.

current_stock is a materialised running total. It is mutated only by:

  • type = 'in' → +quantity
  • type = 'out' → −quantity
  • type = 'adjust' → +quantity (signed)

Indexes recommended for the workload:

  • idx_mov_ts — stock_movements(timestamp)
  • idx_mov_type_ts — (type, timestamp) for Q4
  • idx_prod_cat — products(category) for Q2
  • idx_prod_low — (current_stock, reorder_level) for Q1

Engine limitations: subqueries, UNION and window functions are parsed as unsupported and reported as clean errors rather than silently ignored.