Monday, September 15, 2025

Week 17

Sometimes at work I need to match rows by a range, not by IDs. Example: putting students into GPA bands (like “Honors,” “Good Standing,” “Probation”). There’s no foreign key for that—the match is “does this GPA fall between the band’s min and max?”

English:
“Match each student to the GPA band whose range includes the student’s GPA.”

SQL:

SELECT student.id, student.name, student.gpa, gpa_band.band_name FROM student JOIN gpa_band ON student.gpa BETWEEN gpa_band.min_gpa AND gpa_band.max_gpa ORDER BY gpa_band.band_name, student.name;

My opinion of SQL & what trips me up

SQL feels like asking the database a question in a very exact way. I like that I can describe what I want and let the database figure out how to get it. It’s not “hard,” but it is picky—small details change the result.

What I still have to slow down for:

  • Turning English into steps. Questions like “students who never took course X” or “for each department, who has the top score?” make me pause and plan before I write the query.

  • Counting and then filtering. First you group and count, then (if needed) filter based on that count—easy to mix up the order.

  • Joins in general. Missing one condition can duplicate rows; adding the right condition fixes it.

  • NULLs. Equality doesn’t work the way you expect with NULL, so I double-check with IS NULL when needed.

Overall, I’m liking SQL more each week. Once I think in sets (tables in, table out), the patterns start to repeat and it gets much easier.

No comments:

Post a Comment

Week 28

This week’s focus on concurrency and threads felt like a big shift from everything we have done so far. Until now, processes always felt sim...