← SQL workplace practice

Procurement tradeoffs and award evidence · Original fictional data · Free files and full answers

Compare single-supplier kit awards including one freight charge

A kit needs6A and3B. Every supplier must cover both SKU quantities within capacity and MOQ. Charge the supplier maximum quoted shipping once. Return supplier,goods_cents,freight_cents,total_cents sorted total,supplier.

Use this fixed business case to build a checked CSV and a replayable SQL handoff. No account required. Scenario datasets are shared across related exercises; each exercise has its own decision and output contract.

Your output contract

  1. A kit needs6A and3B. Every supplier must cover both SKU quantities within capacity and MOQ. Charge the supplier maximum quoted shipping once. Return supplier,goods_cents,freight_cents,total_cents sorted total,supplier.
  2. Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
  3. These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.

Return columns exactly as supplier, goods_cents, freight_cents, total_cents. Sort order follows the task. Output has 3 rows; an empty CSV field means NULL.

Source data

bids

9 source rows · Download bids CSV

id INTEGERsupplier TEXTsku TEXTunit_cents INTEGERshipping INTEGERcapacity INTEGERmoq INTEGERlead_days INTEGERexpires INTEGERrisk_low INTEGERrisk_high INTEGER
1AlphaA1002001223200100
2BetaA9035084525100400
3GammaA110020121000
4AlphaB2002001024200100
5BetaB18035062625100400
6GammaB230012121000
7DeltaA8050055730300900
8DeltaB17050084730300900
9EpsilonA50250101825100300

kit

2 source rows · Download kit CSV

sku TEXTunits INTEGER
A6
B3

amendments

3 source rows · Download amendments CSV

line TEXTold_units INTEGERnew_units INTEGERunit_cents INTEGER
L158100
L240200
L303150
Field dictionary and schema
bids:
  id INTEGER — Stable source record identifier; not a row position.
  supplier TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  sku TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  unit_cents INTEGER — Exact integer monetary cents; no implicit currency conversion.
  shipping INTEGER — Fixed supplier order freight in cents.
  capacity INTEGER — Maximum quantity this bid can supply.
  moq INTEGER — Minimum nonzero order quantity.
  lead_days INTEGER — Elapsed delivery lead time in days.
  expires INTEGER — Expiry boundary; the goal declares whether equality is eligible.
  risk_low INTEGER — Lower supplier-level risk allowance in cents.
  risk_high INTEGER — Upper supplier-level risk allowance in cents.

kit:
  sku TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  units INTEGER — Physical unit quantity, not a monetary amount.

amendments:
  line TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  old_units INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.
  new_units INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.
  unit_cents INTEGER — Exact integer monetary cents; no implicit currency conversion.

Download complete SQLite setup

A method you can reuse

  1. A kit needs6A and3B. Every supplier must cover both SKU quantities within capacity and MOQ. Charge the supplier maximum quoted shipping once. Return supplier,goods_cents,freight_cents,total_cents sorted total,supplier.
  2. For the first output record, supplier = Gamma; goods_cents = 1350; freight_cents = 0; total_cents = 1350.
  3. Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.

Watch for this wrong turn

Adding shipping on every kit line overstates a freight charge quoted once per supplier order.

Run and check in SQLite

Your SQL runs locally in the existing SQLite worker. The checker compares every column, row, type, value and row order with this fixed output. It accepts equivalent SELECT or WITH queries. Browser storage keeps your SQL on this device when available.

Complete worked SQL and expected output
WITH x AS (SELECT b.supplier,SUM(k.units*b.unit_cents) goods,MAX(b.shipping) freight,COUNT(*) lines,SUM(k.units>=b.moq AND k.units<=b.capacity) feasible FROM bids b JOIN kit k USING(sku) GROUP BY b.supplier) SELECT supplier,goods goods_cents,freight freight_cents,goods+freight total_cents FROM x WHERE lines=(SELECT COUNT(*) FROM kit) AND feasible=lines ORDER BY total_cents,supplier;
"supplier","goods_cents","freight_cents","total_cents"
"Gamma","1350","0","1350"
"Alpha","1200","200","1400"
"Beta","1080","350","1430"
Reference SQL · Complete expected CSV · Empty answer CSV

Choose another SQL task · Original data exception cases · Larger workplace projects