Complex SQL Query: Watch Me Write It
Vložit
- čas přidán 21. 07. 2024
- 📝 Get my free SQL Cheat Sheets: www.databasestar.com/get-sql-...
🎓 Learn and become confident in SQL: databasestar.mykajabi.com/sql...
If you need to write an SQL query and you think it will be pretty complex, don't fear!
Writing a complex SQL query is about starting small and iterating until you get the result you want.
In this video, I'll demonstrate a problem that needs to be solved with SQL, load some sample data, and write the query step-by-step.
The demo is shown in MySQL, but the concepts can be applied to any SQL database.
Hopefully you can use this approach with your own complex query.
If you like this style of video, let me know in the comments below.
⏱ TIMESTAMPS:
00:00 - What we will cover
00:29 - The problem
01:45 - Create tables and sample data
03:34 - The first SELECT query
07:56 - Finding the top scores
09:53 - Changing what we see
13:40 - Advice if you want to do this yourself
🔗 VIDEO LINKS:
GitHub script for sample data: github.com/bbrumm/databasesta...
HackerRank question: www.hackerrank.com/challenges... - Věda a technologie
You are constantly producing ONLY top-notch videos. Kudos to you and please, keep this kind of stuff. It is of invaluable importance for us to see the "inner kitchen" of how professionals write complex queries.
Thanks for the kind words! I’m glad you and others like this kind of video. It’s the first of this kind that I have made (step by step on writing a complex query) so I’ll keep making more of them.
I love this video and find it incredibly useful. Yes, please, do more videos breaking down the thought process of writing complex queries. Funny, I was like, 'you can't put that in the WHERE clause it goes in a HAVING clause!'... and then that's what you demonstrated & the reason behind it. That boosted my confidence.
Thanks, glad you like it! Great to hear you had that thought as you were watching it - I did that deliberately to show what the issue would be.
Amazing videos, enjoy actually your doing and healing the complex queries. Keep up the great content!
Thanks!
That has been the best video to teach complex SQL in a very light manner!
Thanks a lot!
You need more recognition, your videos are really helpful!
Thanks!
Very concise. Thank you for this video!
Glad it was helpful!
This is so good and well explained! This is perfect!
Glad it was helpful!
Thanks Ben an excellent video. At my work we write a lot of complex queries. I have often wondered if there is a 'best practice' approach to writing them.
That’s good to hear you liked it and found it useful.
This is very useful! I would love to see more.
Thanks! Yeah I have more like this planned.
Thank you for this well explained video, appreciate your efforts to produce this perfect content.
You're welcome! Glad you liked it
Thank you, i am new to SQL and your chanel. You help me a lot sir.
No problem, great to hear it’s helping!
it was a moment when u do a references using pk and fk for the tables? or u just straight do the inner joins ? great vid
Thanks! You usually perform joins on the foreign key and primary key, but not always.
Unique Tutorial
Thanks!
You didn't provide the link to the hackrank question as you claimed.
Ah good point! Here's the link: www.hackerrank.com/challenges/full-score/problem
I'll also add it to the description.
how to fetch first 3 and last 3 records in oracle sql in single query
One way I think you could do it is a query that gets the first 3 rows (using row_number and a where clause) and filter on the top 3 and the bottom 3. Perhaps 2 queries combined with a Union All could be used too.
please, next video about : "Complex PL/SQL Query: Watch Me Write It"
That’s a good idea!