← SQL workplace practice

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

Find each bid usable quantity interval after business demand bounds

Buyer permits orders between4 and9 units. Intersect each A bid MOQ/capacity interval with that buyer range. Return bid_id,min_usable,max_usable only when intersection nonempty. Sort bid_id.

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. Buyer permits orders between4 and9 units. Intersect each A bid MOQ/capacity interval with that buyer range. Return bid_id,min_usable,max_usable only when intersection nonempty. Sort bid_id.
  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 bid_id, min_usable, max_usable. Sort order follows the task. Output has 5 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. Buyer permits orders between4 and9 units. Intersect each A bid MOQ/capacity interval with that buyer range. Return bid_id,min_usable,max_usable only when intersection nonempty. Sort bid_id.
  2. For the first output record, bid_id = 1; min_usable = 4; max_usable = 9.
  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

Testing only a single nominated quantity hides the range of order sizes a quote can actually serve.

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
SELECT id bid_id,MAX(moq,4) min_usable,MIN(capacity,9) max_usable FROM bids WHERE sku='A' AND MAX(moq,4)<=MIN(capacity,9) ORDER BY id;
"bid_id","min_usable","max_usable"
"1","4","9"
"2","4","8"
"3","4","9"
"7","5","5"
"9","4","9"
Reference SQL · Complete expected CSV · Empty answer CSV

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