Sets multiplicity and evidence · Original fictional data · Free files and full answers
Compute duplicate-preserving excess rows between two feeds
Compare feed one against two by key multiplicity. Return key,excess_copies=max(0,count_one-count_two), positive only, sorted key.
Use this fixed business case to build a checked CSV and a replayable SQL handoff. No account required. Scenario datasets are shared across related exercises; each exercise has its own decision and output contract.
Your output contract
- Compare feed one against two by key multiplicity. Return key,excess_copies=max(0,count_one-count_two), positive only, sorted key.
- Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
- These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.
Return columns exactly as key, excess_copies. Sort order follows the task. Output has 2 rows; an empty CSV field means NULL.
Source data
features
10 source rows · Download features CSV
| entity TEXT | feature TEXT |
|---|---|
| A | x |
| A | y |
| A | y |
| B | x |
| B | y |
| C | x |
| D | z |
| E | x |
| E | y |
| E | z |
feeds
10 source rows · Download feeds CSV
| feed TEXT | key TEXT |
|---|---|
| one | a |
| one | a |
| one | b |
| one | d |
| two | a |
| two | c |
| two | d |
| three | a |
| three | d |
| three | e |
evidence
5 source rows · Download evidence CSV
| claim TEXT | source TEXT | owner TEXT |
|---|---|---|
| C1 | s1 | O1 |
| C1 | s2 | O1 |
| C2 | s3 | O1 |
| C2 | s4 | O2 |
| C3 | s5 | O3 |
Field dictionary and schema
features: entity TEXT — Literal business key or category label. Match exactly and retain NULL where present. feature TEXT — Literal business key or category label. Match exactly and retain NULL where present. feeds: feed TEXT — Literal business key or category label. Match exactly and retain NULL where present. key TEXT — Literal business key or category label. Match exactly and retain NULL where present. evidence: claim TEXT — Literal business key or category label. Match exactly and retain NULL where present. source TEXT — Literal business key or category label. Match exactly and retain NULL where present. owner TEXT — Literal business key or category label. Match exactly and retain NULL where present.
A method you can reuse
- Compare feed one against two by key multiplicity. Return key,excess_copies=max(0,count_one-count_two), positive only, sorted key.
- For the first output record, key = a; excess_copies = 1.
- Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.
Watch for this wrong turn
EXCEPT removes duplicates and cannot report an extra copy of a key present in both feeds.
Run and check in SQLite
Your SQL runs locally in the existing SQLite worker. The checker compares every column, row, type, value and row order with this fixed output. It accepts equivalent SELECT or WITH queries. Browser storage keeps your SQL on this device when available.
Complete worked SQL and expected output
WITH a AS (SELECT key,COUNT(*) n FROM feeds WHERE feed='one' GROUP BY key), b AS (SELECT key,COUNT(*) n FROM feeds WHERE feed='two' GROUP BY key) SELECT a.key,a.n-COALESCE(b.n,0) excess_copies FROM a LEFT JOIN b USING(key) WHERE a.n>COALESCE(b.n,0) ORDER BY a.key;
"key","excess_copies" "a","1" "b","1"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects