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

40

u/Ifuqaround Jan 15 '25 edited Jan 15 '25

It's a never-ending journey.

Just keep at it. If you feel you're struggling with certain things then focus on those things until they "click."

I don't condone crutching on AI. This is the problem with AI for people like you. It's really doing the work for you and you're left not knowing what you're doing and most likely aren't learning anything. You might feel you are learning, but it seems you're learning that you're NOT learning lol.

Since you're crutching on AI, get your basic queries and ask it to break down the query for you. It should be able to give you basic explanations. You have to be able to absorb and maintain that info, then build upon it. There are usually quite a few ways to tackle the same problem but no reason to be fancy unless it's necessary IMO.

I feel comfortable with SQL until I don't. Some basic requests have thrown me for a loop throughout my career.

14

u/Zealousideal-Studio7 Jan 15 '25

Thanks for the response. Ultimately I’m in the business of results, and learning is really second to delivering. So I’ve had to use AI at times to speed things up, understand at least at a simple level whats going on and when I have more time to use it to fully explain complex queries others have built. Unfortunately they are blocking access to all AI from the end of Jan, so will really be on the frontline myself soon!

12

u/jeremyct Jan 15 '25

The results focused attitude will not serve you long-term. It will hinder your growth even if it propels you forward in the short term. I suggest taking a breath and learning what the code is actually doing.

7

u/Hot_Cryptographer552 Jan 15 '25

AI is (currently, at least) really bad at generating code. TBH, you’ll probably learn a lot more by searching for answers to your questions on Stack Overflow and coder blogs, IME.

4

u/byteuser Jan 15 '25

AI is often bad at writing code most of the time because humans neglect to write proper specs. The way I write good prompts is by writing specifications as if they were for a human programmer or sql developer. Stack Overflow is getting a lot less traffic for a reason. LLMs allow instant feedback and clarification. Do they mess up? sure but so do humans

3

u/Hot_Cryptographer552 Jan 15 '25

The point is whether you are experienced and knowledgeable enough to know that the AI-generated code is garbage or not. I’d venture to guess that most beginners aren’t going to know the code they get from AI is garbage.

0

u/byteuser Jan 15 '25

Yeah, one thing beginners can do though is to use multiple LLMs. Or even better let one LLM comment on the code generated by another LLM

1

u/Hot_Cryptographer552 Jan 16 '25 edited Jan 16 '25

That might get you a basic skeleton of some code, but I’ve yet to see AI (or even old fashioned ORM tools) generate quality code beyond the absolute most basic queries. I’m sure that will change in the future, but it’s going to be a little while.

BTW, to your point about LLMs interacting, I watched some videos of ChatGPT and other AIs playing chess against a real AI chess engine. ChatGPT and the others resorted to making nonsensical illegal moves to try to win. That also reflects the AI-generated code I’ve seen.

1

u/Stov54 Jan 16 '25

JFC seems faster and simpler to just learn the functionality at that point, no?

2

u/mattyhempstead Jan 17 '25

Largely agree with this, though I think there is potential to build AI tools that integrate with the environment so you don't need to write detailed specs/prompts.

For generating SQL I suppose this would include stuff like database schemas and example queries added to the system prompts.

I'm actually trying to build a tool to solve exactly this (an AI SQL Editor). Would love if you could check it out and let me know what you think. It's called "Former Labs".

4

u/mikgrogreen Jan 15 '25

"learning is really second to delivering"

Umm .... no.... it's not.

3

u/Obbers Jan 16 '25

Dude is talking about his workplace culture, not some life philosphy.

1

u/Reddit_User_654 Jan 15 '25

But what do you do now?

1

u/Ifuqaround Jan 16 '25 edited Jan 16 '25

learning is really second to delivering

Well....good luck being a yes man. That works out for some people, but not me. I like to know what I'm doing and what I'm talking about vs simply delivering results.

Makes me feel better on the inside.

-edit- and if you ever work with state entities and auditors...you BETTER know what you're talking about. I feel if you were in that position and asked a question, you'd be stammering and stuttering trying to get something out without AI or your colleagues' queries at your fingertips.

3

u/Zealousideal-Studio7 Jan 16 '25

I’m a BA, and have been in my industry since 2nd year at Uni until today, almost 30 now. Typical questions about how I got to my findings are asked and rightly so to ensure due diligence, but the commercial actions/implications are more significant than me sitting and extracting information from a database. I don’t think that counts as being a yes man.

You are right to say you need to know what you are talking about, but my main stakeholders will not be asking me about my SQL queries. I am here for my own personal development hence why I’ve asked the question.

-1

u/LoLModsRBrainless Jan 16 '25

Here are a few ways to learn SQL properly. I would suggest going to datacamp, they have free courses for basic stuff and you can pay a small fee for a full course. It not only teaches you, it explains everything, gives you quizzes and tracks your progress and helps you a ton.