AccessionSQL, one case at a time
#035Level 5 of 6 · Scenario 6: The Install List

The worst wall

Scenario 6 · The Install List

The curator's first question will not be how many objects are in trouble, it will be whether the show can be rehung around them. That is a question about walls. If the damage is spread thinly the hang survives; if one wall is carrying most of it, that wall has to be redrawn and the registrar would rather say so now than on the 2nd.

Schema · 5 tables
objects
  • idpkINTEGER
  • titleVARCHAR
  • wingVARCHAR
  • valuationDOUBLE
picks
  • idpkINTEGER
  • object_idINTEGER
  • wallVARCHAR
  • wall_dateDATE
bench
  • idpkINTEGER
  • object_idINTEGER
  • treatmentVARCHAR
  • due_backDATE
loans_out
  • idpkINTEGER
  • object_idINTEGER
  • object_noteVARCHAR
  • borrowerVARCHAR
  • returns_onDATE
holds
  • idpkINTEGER
  • object_idINTEGER
  • raised_byVARCHAR
  • raised_onDATE

Toolkit

SELECT
Choose which columns come back.
FROM
Specify which table to read.
WHERE
Filter rows by a condition.
ORDER BY
Sort the results by a column.
INNER JOIN
Keep only rows that matched in both tables.
IS NULL
Test for a missing value. Never use = NULL.
COUNT(*)
How many rows there are.
GROUP BY
Split the rows into groups first, then aggregate each one.
WITH name AS ( ... )
Name a query and use it below like a table. Several can be chained, and a later one may read an earlier one.
MAX
The largest value in a column.
ROUND(x, 1)
Round to one decimal place.
Objective

Find the wall with the most objects on the install list that any department has something open against. Return the wall, how many of its objects that is, and what percentage of all flagged picks sit on it, rounded to one decimal place.

Your query

starting DuckDB…
loading editor…

Results

No result yet.