Skip to course content
Free SQL course

SQL for Data Analysis and AI

Module 09 Summary

The idea this module was built around

GROUP BY compares exact stored values. Two strings that look identical on screen can group separately, and your category counts are wrong in a way no error message will ever tell you about.

What you can now do

The trap this module removed

Raw counts put New Delhi fourth, behind Mumbai (1,070), Bengaluru (1,069), and Chennai (1,069) - because the city is stored three ways: 'New Delhi' (535), 'New Delhi ' with a trailing space (535), and 'new delhi' (534). Normalised with LOWER(TRIM(city)) it becomes 1,604 and the largest market by a wide margin.

The trailing-space variant is the dangerous one. It is invisible on screen, it groups separately, and nothing about the output suggests anything is wrong.

The honesty this module asks for

LOWER(TRIM(city)) handles case and padding. It will not catch 'N. Delhi', a double space, or a misspelling. A normalisation rule is a stated assumption with known gaps - write those gaps down, and apply the rule in exactly one place so it can be changed in exactly one place.

Before you move on

Run a LOWER(TRIM()) count against the messiest text column you work with. Compare it to the raw count. The gap is how wrong your category reporting has been.