Count Records Present in A but Not B
Problem statement
The records_a and records_b tables each contain one row per unique record identifier.
Return one row containing the number of identifiers that appear in records_a but do not appear in records_b. Name the output column record_count.
| Table | Column | Description |
|---|---|---|
records_a | record_id | Identifiers in the first dataset. |
records_b | record_id | Identifiers in the second dataset. |
Table schema
MySQLPostgreSQLPandas
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
records_a
One row per unique identifier in the first dataset.
| Column | Type | Nullable | Description |
|---|---|---|---|
| record_idPK | Integer | No | A record identifier in the first dataset. |
records_b
One row per unique identifier in the second dataset.
| Column | Type | Nullable | Description |
|---|---|---|---|
| record_idPK | Integer | No | A record identifier in the second dataset. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| record_count | Integer | No | The number of identifiers in records_a that are absent from records_b. |
Row order: must match exactly. Numeric tolerance: 0.
Constraints
- Each table contains between
0and100000rows. - Every
record_idis a non-null integer. - Each
record_idis unique within its table. - The result always contains exactly one row, including when the count is
0.