Counting permitted equipment plans

An equipment-rental company stores proposed allocations of its fleet using this SQL table definition. Counts are whole numbers of equipment units. Equipment not loaned or held in reserve may remain idle.


SQL
CREATE TABLE FleetPlan (
    plan_id INTEGER PRIMARY KEY,
    total_units INTEGER NOT NULL,
    loaned_units INTEGER NOT NULL,
    reserve_units INTEGER NOT NULL,
    CHECK (total_units >= 0),
    CHECK (reserve_units BETWEEN 2 AND 5),
    CHECK (loaned_units >= reserve_units),
    CHECK (loaned_units + reserve_units <= total_units)
);


Consider a new plan with total_units equal to 12 and an unused plan_id. There are no other constraints or triggers. SQL BETWEEN includes both endpoints.


Find the maximum permitted loaned_units, in equipment units, and the number of distinct integer pairs (loaned_units, reserve_units) that satisfy every constraint. Report both answers as exact integers.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More SQL Basics Questions: