Complex SQL Query: Watch Me Write It

Sdílet
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

Komentáře • 34

  • @eminjs2319
    @eminjs2319 Před rokem +7

    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.

    • @DatabaseStar
      @DatabaseStar  Před rokem +2

      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.

  • @melspiglet
    @melspiglet Před rokem +2

    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.

    • @DatabaseStar
      @DatabaseStar  Před rokem

      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.

  • @-.-smile
    @-.-smile Před rokem +1

    Amazing videos, enjoy actually your doing and healing the complex queries. Keep up the great content!

  • @kanugupta1044
    @kanugupta1044 Před 11 měsíci +1

    That has been the best video to teach complex SQL in a very light manner!

  • @katsukido2931
    @katsukido2931 Před rokem

    You need more recognition, your videos are really helpful!

  • @nirshadnijam2291
    @nirshadnijam2291 Před rokem +1

    Very concise. Thank you for this video!

  • @Franaman
    @Franaman Před rokem +1

    This is so good and well explained! This is perfect!

  • @rachaelhanna8523
    @rachaelhanna8523 Před rokem +1

    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.

    • @DatabaseStar
      @DatabaseStar  Před rokem

      That’s good to hear you liked it and found it useful.

  • @michellemontemayor4064

    This is very useful! I would love to see more.

    • @DatabaseStar
      @DatabaseStar  Před rokem

      Thanks! Yeah I have more like this planned.

  • @obadmatar
    @obadmatar Před rokem

    Thank you for this well explained video, appreciate your efforts to produce this perfect content.

  • @tuilathang97
    @tuilathang97 Před rokem

    Thank you, i am new to SQL and your chanel. You help me a lot sir.

  • @damishito
    @damishito Před rokem

    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

    • @DatabaseStar
      @DatabaseStar  Před rokem

      Thanks! You usually perform joins on the foreign key and primary key, but not always.

  • @oracle_professor
    @oracle_professor Před rokem

    Unique Tutorial

  • @engr_mark
    @engr_mark Před rokem

    You didn't provide the link to the hackrank question as you claimed.

    • @DatabaseStar
      @DatabaseStar  Před rokem

      Ah good point! Here's the link: www.hackerrank.com/challenges/full-score/problem
      I'll also add it to the description.

  • @sqlmaster9816
    @sqlmaster9816 Před rokem

    how to fetch first 3 and last 3 records in oracle sql in single query

    • @DatabaseStar
      @DatabaseStar  Před rokem +1

      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.

  • @ramsay9912
    @ramsay9912 Před rokem

    please, next video about : "Complex PL/SQL Query: Watch Me Write It"