r/SQL • • 2d ago

MySQL need good sql resources

i wanted to practice sql and to be able to answer qns , i have noticed that i am struggling a bit when there is two tables give and the qn has to do something with joins and all , in theory i understand how the joins work but i am unable to implement it .I need resources which can help me in advancing my sql like CTE and window function . Is there any youtube channel or anything which will help

2 Upvotes

28 comments sorted by

1

u/CoolDaddy4 2d ago • Bravo

I started by watching Data with Baraa, https://www.youtube.com/watch?v=SSKVgrwhzus

1

u/Eastern-Stable-7576 2d ago

Thanks! I have watched his power bi videos Btw i wanted to ask if after completing the vdo will i be able to solve leetcode sql medium-hard qns?

1

u/pythonQu 2d ago

you'll need to also do practice problems to solidy your understanding.

1

u/Eastern-Stable-7576 2d ago

Yeah , like i was able to solve lc easy but was getting stuck in medium to hard qns

1

u/pythonQu 2d ago

For me, when I started thinking about the logical execution of sql engine, that's when things started clicking for me which helped in the sql basics. But once you can join a 2 tables together, then can join 3 tables together - tho probably would want to look at CTE's at that point.

1

u/Blitzsturm 2d ago

a lot of people use AI tools to write code, but it's also an exceptional teacher. Use it to generate an example scenario where each of the types of joins are ideal then guide you through a lesson on each.

1

u/Eastern-Stable-7576 2d ago

Ahh okayy i will surely give it a try . tq

3

u/Blitzsturm 2d ago edited 2d ago

hop into your favorite and throw down a prompt like:

I'm studying SQL and am wanting to focus on the topic of joins. Generate code to create table schema and populate it with simple example data in <your database type> and devise a lesson plan to explain the best use of every type of join and a give me a task to perform each join. I'll go through them individually, ask questions as needed and complete them so that I can fully understand how the join works and in what scenario each is best. When done, generate a study guide or cheat-sheet to help me remember the lesson.

* It's important to note AI can be a powerful tool, but you should never outsource your own thinking to it and be lazy. Use it to help strengthen your knowledge, check your work and if you need it to actually do work for you, make sure you understand everything it's doing and why; make sure it explains anything you're unsure of. You need to be able to fix understand and fix things without it but ignoring it completely leaves a powerful tool off the table.

1

u/Eastern-Stable-7576 2d ago

Omg thank you sm😭😭

1

u/xobeme 2d ago

This is a great suggestion. Once you learn the syntax, reading examples of code is the best way to learn it...

1

u/pythonQu 2d ago

omg, I was where you're at. I completed a data analytics in september and JOIN's was for me tough to understand. I have a better handle on it now. I've been using runtime.school resource to learn and Data Lemur also and claude to clarify my understanding.

1

u/Eastern-Stable-7576 2d ago

😭😭tqsm

2

u/conor-robertson 2d ago

You should check out QueryCase for a fun way to learn and explore SQL!

1

u/SteveDBA 2d ago

If you're willing to spend a little on a subscription, I'd recommend checking out Pluralsight, CBT Nuggets, or LinkedIn Learning. They have structured SQL courses that cover everything from basic joins to more advanced concepts like CTEs and window functions.

1

u/ReassuranceThumbsUp 2d ago

I like learnsql

One time payment for all their SQL courses that let you write and practice code within the website

It does a good job teaching all the different functions and why they are used with example databases, good starting point.

1

u/Top_Tooth_6995 2d ago

Ok here’s my thought (1) you need more and more reps. If you don’t understand something at first, you can’t visualize the join in your head, or you don’t know why you need a join in the first place, i promise you it is because you have not played with the concept enough. You have not done problem after problem, after problem. Your brain has not learned. I promise you. Your brain can learn JOINs. You need an environment that will allow you to practice, over and over, so you can get those reps in. And yes, this is where I urge you to try my free sql course, SQLMaxx Learn, which embodies the philosophy I essentially just described 👍

1

u/jaiagreen 2d ago

SQLzoo.net is great for practice.

1

u/ReleaseTheBlacken 2d ago

Completely free SQL catalog at learn dot inkwelltools dot com

1

u/nicopassaglia 2d ago

"I get joins in theory but can't write them" usually means you need a routine, not another video. This one works:

  1. Decide what one row of the answer is (one customer? one order?). Start FROM that table.
  2. Add one join and run it with SELECT * before anything else. Look at the row count. If it went up, you now have several rows per customer, and that changes every COUNT and SUM after it.
  3. Only then add the filter, the GROUP BY, the next join. One change per run.

Most wrong join answers come from skipping step 2.

Do that on 20 or 30 small problems and CTEs come almost free: a CTE is just a name for one of those steps. Window functions are the next thing after GROUP BY clicks: same idea, but you keep every row.

Disclosure: I built getsheetdrill.com, where you can practice exactly this in the browser, free: a lesson on joins, one on subqueries and CTEs, and pages with exercises on window functions (getsheetdrill.com/sql/reference/joins is a good start). It runs SQLite, not MySQL, but for joins, CTEs and window functions what you write is the same in MySQL 8.

1

u/Discordbothost 1d ago

Try a LEFT JOIN with two customers, one with two orders and one with none. Predict the three joined rows, then group by customer and compare COUNT(*) with COUNT(order_id). Why does the customer with no orders get a 1 from the first count?

1

u/Time_Advertising_412 1d ago

I'm old school book by nature. Pick up "Practical SQL" by Anthony DeBarros or one of the SQL Server For Developers books by Murach or "SQL For Smarties" by Joe Celko

1

u/FunAd6672 1d ago

Joins usually make sense in your head until you have to stare at two columns and pick the right side for a left join.

1

u/0utlawViking 2h ago

For learning SQLBolt and W3Schools, and HackerRank's SQL challenge for hands on practice. For joins, try solving questions with two small tables and understand how the rows connect instead of memorizing the syntax. Once you're comfortable, move on to CTEs and window functions Youtube also has some great free tutorials.

0

u/xobeme 2d ago

Dude, google is your friend...

1

u/Eastern-Stable-7576 2d ago

I did search and stuff but couldn't find smthg solid

1

u/Available_Safe1818 9h ago

Yeah, right. Google just can't find anything. :D