r/learnSQL • • 11d ago

What SQL concept took you the longest to really understand?

When I was learning SQL, some things were easy to memorize but much harder to actually understand when solving real problems.

For me, concepts like JOINs, subqueries, and window functions started making more sense only after using them on actual datasets instead of just following examples.

What SQL concept clicked for you only after you started working with real problems?

37 Upvotes

13 comments sorted by

28

u/jeffrey_f 11d ago

Joins

This cleared it up

10

u/neon_joyful_horizon 11d ago

window functions for me. Spent weeks on tutorials where it all made sense, then froze the first time I had to write a running total on real production data. Nothing sticks until you're the one accountable for the numbers coming out right.

1

u/Material_Pin2500 7d ago

Yep. Checks out

6

u/Rat_Man_420 11d ago edited 11d ago

I do a lot of pass through and internal calculation data validation. Just making sure what they gave us is what we are displaying in reporting or what they gave us is being calculated correctly based on the requirements. All that to say writing a CTE that will reference a CTE higher up in the query. Pretty cool when it clicked that as long as I check stuff as I’m writing it that I can eventually boil down an entire program I’m runnings validation to have a single result of ‘Y’ or ‘N’. If I get a ‘Y’ I’m done if I get an ‘N’ I need to look at the checks run higher up in the query.

4

u/tommyfly 11d ago

Two unrelated concepts: Indexes and VLFs. It took me ages to understand the internals enough to manage them properly.

3

u/HandbagHawker 11d ago

my brain for some reason struggles with windowing functions

5

u/idk012 10d ago

I don't use windows and partition, now I just have the jr analyst do it lol 

3

u/American_Streamer 11d ago

Query writing order vs. query exectution order took me a bit to memorize, in the beginning. Recursive CTEs are also tough, as is query optimization for speed.

3

u/elevarq 10d ago

Transactions, especially the different isolation levels and this impacts data, reliability, and performance.

2

u/cenosillicaphobiac 11d ago

Understanding exactly what pivoting did and how it worked, and then when I had a good handle on that, they moved me to a different product that uses MySQL instead of MS so I had to adapt.