Skip to content
Astera Technology

Which active customer accounts have no active owner?

Separate unassigned accounts from accounts linked to inactive or missing staff.

Define the decision and input records

The join accepts only active staff while the WHERE clause limits the customer side to active accounts. That preserves an account whose named owner is inactive, instead of accidentally dropping it. The issue label separates a missing assignment from an unusable assignment because their follow-up actions differ.

All records below are synthetic. Create these tables in a fresh SQLite database before running the read-only query. Quantities are units; monetary values are integer HKD cents, so divide by 100 when presenting HK dollars.

Selected synthetic input rows; complete related records follow in SQL
idemailowner_idactive
C1 Alex@example.test S11
C2alex@EXAMPLE.testS11
C3NULL (unknown or absent)NULL (unknown or absent)1
C4bee@example.testS21
C5old@example.testS20
Download editable CSV ↓
Complete runnable synthetic fixture (SQLite)
CREATE TABLE customer_accounts(id TEXT PRIMARY KEY, email TEXT, owner_id TEXT, active INTEGER);
CREATE TABLE staff(id TEXT PRIMARY KEY, active INTEGER);
INSERT INTO staff VALUES ('S1',1),('S2',0);
INSERT INTO customer_accounts VALUES ('C1',' Alex@example.test ','S1',1),('C2','alex@EXAMPLE.test','S1',1),('C3',NULL,NULL,1),('C4','bee@example.test','S2',1),('C5','old@example.test','S2',0);

Run the query and compare the result

Read-only SQLite query
SELECT c.id,c.owner_id,
 CASE WHEN c.owner_id IS NULL THEN 'unassigned' ELSE 'inactive_or_missing' END AS issue
FROM customer_accounts c LEFT JOIN staff s ON s.id=c.owner_id AND s.active=1
WHERE c.active=1 AND s.id IS NULL ORDER BY c.id;
Result from the supplied SQLite fixture
idowner_idissue
C3NULL (unknown or absent)unassigned
C4S2inactive_or_missing
Download editable CSV ↓

C3 is unassigned and needs an ownership decision. C4 refers to inactive S2 and needs reassignment. C5 is inactive and is intentionally excluded. For a handover, confirm the receiving colleague and transfer only the authorised customer work.

Apply the result within its limits

This checks coverage, not workload, availability or access rights. A system with teams, multiple owners or temporary deputies needs explicit responsibility rules and a different relationship table.

The supplied setup and result were executed with SQLite. Adapt the schema and status rules to a test copy of your system, then agree the expected result with the process owner. These examples have not been tested on other database platforms.

Related resources