Separate the catalog category totals from the rule that selects sufficiently large totals.
These tables are already loaded at the start of this lesson.
gearOne row represents one equipment catalog entry.
| Field / SQL type | Meaning | Rules |
|---|---|---|
gear_id · integer | Identifier of the equipment entry. | Primary key. Required; cannot be NULL. |
name · text | Equipment display name. | Required; cannot be NULL. |
category · text | Equipment grouping, such as repair, outdoors or art. | Required; cannot be NULL. |
fee · numeric(6,2) | Daily borrowing charge in currency units, stored to two decimal places. | Required; cannot be NULL. |
available · boolean | Whether the equipment is available to borrow: true or false. | Required; cannot be NULL. |
note · text | Optional handling note. | Nullable; NULL means no note is recorded. |
Only note may be missing. Category labels are sample values, not an enforced vocabulary. No currency code or nonnegative-fee constraint is declared; a fee is a daily charge, not a count of items.
totalsOne row represents one category group.
| Field / SQL type | Meaning | Rules |
|---|---|---|
category · text | Grouping label from gear.category. | Logical group key, not a physical primary key. Required in the base table. |
total_fee · numeric | Sum of gear.fee in this group, in daily borrowing currency units. | Computed value; no fixed precision or scale. Each nonempty group has required fee inputs, so its total is known. |
This FROM-subquery alias exists only within the statement. Grouping yields one row per label, including at most one NULL-label group where allowed; it creates no stored table, key or foreign key.
Write your query in script.sql. Use Run to inspect it, then Submit.
Alias the parenthesized FROM query so its totals become outer columns.