0%

Ask Precise Questions · capstone

Capstone project: Project: Build a Lending Shortlist

The lending desk needs a two-item shortlist for a community presentation. Events equipment and electronics may qualify, but anything with a usual loan period above fourteen days should stay out. The person reading the report wants clear headings and the most flexible choices first.

Open the new shortlist.sql file. It begins with a broad three-column query:

SELECT asset_tag, name, loan_days
FROM items;

Replace it with one complete query that meets this brief:

  • Return three columns headed tag, item, and days, in that order.

  • Keep events or electronics items, and apply loan_days <= 14 to both categories.

  • Put larger loan periods first, then names alphabetically, then IDs from low to high.

  • Keep at most two rows.

You have used every part of this question in search.sql, but this file does not provide the clause-by-clause answer. Start with the result shape: choose the three stored columns and give them their requested headings. Then write the row filter in plain language before translating its two category alternatives and shared period rule.

Once the matches are right, make their order complete. Days decide first, names settle equal days, and IDs settle repeated names. Put the limit last so it keeps rows from that deliberate order.

Leave the brief beside your editor while you work. Each bullet should have a visible home in the statement: result headings after SELECT, admission rules after WHERE, priorities after ORDER BY, and the maximum after LIMIT.

Press Run and find the new section after any earlier exercise files:

== shortlist.sql ==
Columns: tag | item | days
EV-205 | Projector screen | 14
EV-101 | Folding table | 7

The twenty-and-a-half-day portable speaker is electronics, but it is over the limit. The projector qualifies at two-and-a-half days, but only the first two rows survive the completed order.

Submit tries catalogs with tied periods, repeated names, late-inserted strong matches, irrelevant tools, and no qualifying items. A no-row result should remain a successful query with the same three headings.

If your result is close, compare one part of the brief at a time: headings, admitted rows, their exact order, then the number kept. That keeps a small mismatch from turning into a rewrite of the whole statement.

You have turned a real lending request into an answer that is narrow, readable, and predictable.

Task

Build shortlist.sql from the lending brief above. Return tag, item, and days for qualifying events or electronics items, order the result completely, and keep at most two rows.

Run the report, compare each part with the brief, and submit it.