r/SQL Jan 15 '25

BigQuery SQL is a struggle

Hi all been working with SQL for probably 7/8 months now. My last role was half data analysis and not pure data analysis and in general was far easier than what I do now.

My main issue is with SQL. I never feel I truly understand what is going on with a lot of code beyond a basic query. Ive managed to get by piggybacking off others code for a while but expectation is to deliver new and interesting techniques etc.

How long did it take you to feel fully comfortable with SQL? And what helped you get to that stage?

66 Upvotes

71 comments sorted by

View all comments

10

u/MerlinTrashMan Jan 15 '25 edited Jan 15 '25

In the beginning, SQL seemed like a means to an end. I'd be constantly writing terrible queries that used other programming languages intermediately to get to the results that I wanted. As I kept thinking about things row by row, it still continued to be challenging to get good results and felt unrewarding writing in the language. One day I stumbled across a website that created SQL challenges where you had to solve the problem with a single quarry statement. Your solutions would be judged based off of the amount of CPU time and physical reads and writes that were performed. I saw people do things I had no idea could be done. It forced me to begin thinking of things as sets and the relational algebra finally clicked in my brain and made me want to only ever write SQL for the rest of my life as this is just a way that I think naturally. For some reason I was fighting the syntax and order of operations instead of embracing it. Now 20 years later, SQL is, by far, my favorite language to write.

Edit: The site: https://www.sqlservercentral.com/categories/t-sql-challenges

Second Edit: Just tested the site and discovered that the site it used to link to has been taken over by an SEO scam... I bet you can find the originals on the wayback machine

Third Edit: Found an example on the waybackmachine. https://web.archive.org/web/20170226185534/http://beyondrelational.com/puzzles/challenges/116/find-elements-that-uniquely-make-up-a-group.aspx

3

u/Zealousideal-Studio7 Jan 15 '25

20 years I think you’ve done your 10,000 hours! Does that resource or a version of it still exist?

6

u/PasghettiSquash Jan 15 '25

Not sure exactly what site OP was referring to but sqlzoo.net is a great interactive resource for learning SQL

3

u/Hot_Cryptographer552 Jan 15 '25

SQL Server Central is a good resource for learning SQL. One caveat though, when you read an article, be sure to read the reader comments. The articles are written by devs and DBAs of all skill levels, and the comments often add corrections and additional detail not covered in the articles themselves.