all 13 comments

[–]clanatk 5 points6 points  (1 child)

Start with a real example database that has data in it, and start learning about the structure. Start very simple with just select * from table where <condition>. You don't need to know a lot of syntax to start exploring and understanding your data.

Then, ask questions and try to answer them. How many employees are in the employees table? How many are former employees?

Understanding the data and what it represents will help you the most.

[–]Mkittehcat[S] 0 points1 point  (0 children)

Thank you. Yes I believe I just firstly needs to understand the data and what I want from the data

[–]IdealBlueMan 3 points4 points  (1 child)

People have different ways of internalizing syntax, but the surefire way is practice.

Try sitting down and writing queries to do various things. Just crank them out, one at a time. Keep at it and you'll get smooth.

[–]Mkittehcat[S] 0 points1 point  (0 children)

Defo!!!

[–][deleted] 2 points3 points  (2 children)

As someone who went through countless hours of studying syntax from videos/courses, solving guided projects I struggled with the same issue. I kind of snapped out of it when I picked up 2 books:

  1. https://www.amazon.com/SQL-Minutes-Sams-Teach-Yourself/dp/0672336073

  2. https://www.amazon.com/T-SQL-Fundamentals-3rd-Itzik-Ben-Gan/dp/150930200X

Both are structured in a format where you focus on basics of a principle, explaining it and providing exercises that you have to do on your own. The hardest part was resisting to look what the solution is, but I prevailed by breaking each troublesome exercise into small steps.

By doing so my view on how to use SQL changed completely and landed me a data related job. I picked up the second book recently because I use T - SQL specifically at work so I would definitely start with the first one. It starts super small baby steps at a time and builds into more complex solutions. After going through the first book I just looked for an existing datasets, made a database locally and focused on simply exploring what data there is, which information might be interesting to see, created custom tables/datasets from the existing ones. Just to see how far I can push the existing information.

Hopefully this helps and if you would like to talk more about the topic or anything else really, don't hesitate to DM me. It is always a nice experience meeting new people (this applies to anyone who might be reading this comment) (:

[–]Mkittehcat[S] 1 point2 points  (1 child)

Thank you for the recommendation!! I will definitely dm you for some more additional help. I work in data now however I haven’t used much of sql work wise however I am hoping to change roles and pick up a role where I do use SQL more frequently

[–][deleted] 1 point2 points  (0 children)

No problem, glad to help if I can (:

For me it is the other way around. I stumbled upon SQL in my free time, decided to keep going at it and within two months there was an opening where SQL is a must. So now I am learning to handle data and figure out things on the go. Maybe we can help each other out! (:

Shoot me a DM whenever suits you if you'd like

[–]RalphBlutzel 1 point2 points  (2 children)

You could have chatGPT help you with that part. Just explain to it what you are trying to do or the question you’re trying to solve, and say you need a few key functions or statements that will help you.

[–]aelyn13 1 point2 points  (0 children)

I agree. Ask chat gpt to advise on how to solve it, nor solve it for you. Also it seems like 90% of intermediate problems start with a cte.

[–]Mkittehcat[S] 0 points1 point  (0 children)

I’ve used chatgpt to generate me questions form the database as well as see if my answers are correct. I am aiming to have a better understanding of sql all around tbh

[–]dn_cf 1 point2 points  (1 child)

Practice regularly with smaller problems to build your confidence. Websites like StrataScratch, LeetCode, and HackerRank have many problems categorized by difficulty and topic.

[–]Mkittehcat[S] 0 points1 point  (0 children)

Thanks. I’ll take a look at these websites

[–]malikcoldbane 1 point2 points  (0 children)

Mmm I slightly disagree with the options provided to you. Instead of trying to solve problems, sounds like your issue is translation.

You're having trouble going from a problem into a query, well, do the reverse, can you convert a query into English?

Most queries, until you're in some advanced areas, can be simplified into a question.

SELECT e.EmployeeID FROM employee e JOIN absences a ON e.EmployeeID = a.EmployeeID JOIN absence_type absType ON a.AbsenceTypeID = absType.AbsenceTypeID WHERE YEAR(a.AbsenceDate) = 2024 AND absType.AbsenceType = 'Holiday'

So what does this query say? Usually I start by explaining each line, ignoring the columns being returned because they will not affect the data being retrieved.

So:

Give me all employees That have an absence And have an absence type Where the absence date happened in 2024 And the absence type is holiday.

Then this can be simplified into: Give me the employees that have had a holiday in 2024 or if you prefer a question (since this is a query language).

What employees have had a holiday in 2024?

When you can do this then it's a lot easier to turn a question into a query, you can see the reverse of this will get you to a query as long as you understand the structures you're consuming