What stands out in DuckDB
DuckDB can query a CSV from a SQL prompt. The detail that pays off here is explicit control over how the reader interprets columns. A ticket printed as 001 must still match the badge numbered 001 after the query, even if the first thousand tickets all happen to look numeric.
Walkthrough
- Place market.csv in the directory where you launch the DuckDB CLI. Open a temporary session with duckdb. Run the first query below. Read the ticket and booth columns in the result and verify that 001 appears with all three characters.
- Run the second query to count confirmed registrations per booth. B7 should have two. A1 and C2 should have one each. The ORDER BY clause makes ties reproducible when returning to this file for tomorrow's print run.
- If the manager asks how many booths are occupied, count the groups in the result. If the manager asks how many confirmed registrations came in, add the counts. Those numbers are three and four respectively. Keep the question alongside the query when you share it.
- Try a second copy of the file with a new ticket labeled A06. The all-text import continues to read the ticket field without an exception or a silent conversion. Convert individual numeric measures explicitly later if you add quantities or dollar amounts.
SELECT * FROM read_csv('market.csv', all_varchar=true);SELECT booth, count(*) AS registrations
FROM read_csv('market.csv', all_varchar=true)
WHERE status = 'confirmed'
GROUP BY booth
ORDER BY registrations DESC, booth;Field tip
Put the input filename inside single quotes in SQL. If a path contains spaces it still belongs inside that same string. Starting the CLI in the file's folder keeps the exercise portable between Windows, Linux and macOS.
Where it falls short
Reading every field as text also means numeric sorting is lexical until you cast a field to a number. That is appropriate for badge identifiers. It would put a text quantity of 10 before 2 if reused for inventory.
Try it yourself
A coordinator has four confirmed registrations but only three table signs. Use the grouped result to decide whether the signs are sufficient. The data points to B7 for follow-up. A duplicate assignment may be intentional, so confirm with the organizer before changing it.