Skip to content
Astera Technology

Why are case-sensitive report labels grouped together?

Apply the report’s comparison rule at GROUP BY.

Download complete case notes and answer keys ↓

Prepare the report input

Original report treats a and A as separate labels, but the legacy column declares NOCASE. GROUP BY inherits that comparison unless overridden. BINARY at grouping preserves both raw cases; the displayed minimum also uses BINARY for deterministic representation.

Every record and report rule below is original and fictional. Reproduce the setup in a fresh SQLite test database; input previews include every table in this small fixture.

Synthetic input: labels
idlabel
1a
2A
Download editable CSV ↓
Complete CREATE and INSERT fixture
CREATE TABLE labels(id INTEGER PRIMARY KEY,label TEXT COLLATE NOCASE NOT NULL); INSERT INTO labels VALUES(1,'a'),(2,'A');

Compare misleading and corrected results

Misleading SELECT: reproduce the defect
SELECT min(label COLLATE BINARY) AS label,COUNT(*) AS records FROM labels GROUP BY label ORDER BY label COLLATE BINARY;
Literal misleading result
labelrecords
A2
Download editable CSV ↓
Corrected SELECT
SELECT min(label COLLATE BINARY) AS label,COUNT(*) AS records FROM labels GROUP BY label COLLATE BINARY ORDER BY label COLLATE BINARY;
Literal corrected result
labelrecords
A1
a1
Download editable CSV ↓

Bad group A has two records; corrected groups A and a each have one. BINARY on the displayed minimum chooses a representative; BINARY in GROUP BY is what separates the groups.

Check a fresh boundary case

Add another a. Lowercase a reaches two while uppercase A stays one.

Recreate the original setup in another fresh database, then apply the change and corrected query below. For an empty result, the table displays a labelled empty-result marker rather than a data record.

Boundary change and corrected query
INSERT INTO labels VALUES(3,'a');
SELECT min(label COLLATE BINARY) AS label,COUNT(*) AS records FROM labels GROUP BY label COLLATE BINARY ORDER BY label COLLATE BINARY;
Literal boundary result
labelrecords
A1
a2
Download editable CSV ↓

What counts should the two boundary groups show?

Show the worked answer

A=1 and a=2. Raw labels remain distinct under the supplied case-sensitive report rule.

Related resources