SQL Group By: An Explanation and How To Use It

Поділитися
Вставка
  • Опубліковано 9 лют 2025

КОМЕНТАРІ • 91

  • @DatabaseStar
    @DatabaseStar  2 місяці тому +1

    Want to easily remember the SQL commands for your database? Get my free SQL Cheat Sheets here: databasestar.mykajabi.com/lpkj-sql-cheat-sheets/?

  • @goobygoobdisney
    @goobygoobdisney Рік тому +52

    I don't usually comment on tutorial videos, but this video is so clear I just want you to know how helpful you are for beginners like me

  • @rickvazquez6578
    @rickvazquez6578 2 роки тому +18

    Mate you clarified something for me, I was wondering why I always had to add every other column I had to group by :) plenty helpful keep up the great tutorials!😃

    • @DatabaseStar
      @DatabaseStar  2 роки тому

      Glad it helped you understand the concept further!

  • @sebastianhernandez9631
    @sebastianhernandez9631 Рік тому +4

    I'm preparing for DP-900 exam and I was having a hard time with the Group By statement and aggregate functions. This video has helped me understand it perfectly. Thanks! Subscribed.

    • @DatabaseStar
      @DatabaseStar  Рік тому

      Thanks! I'm glad the video helped you understand it.

  • @user-iv9sh9fc3c
    @user-iv9sh9fc3c 9 місяців тому +2

    you are definitely a database star. Thank you

  • @ordinaryperson-my7qr
    @ordinaryperson-my7qr 2 роки тому +3

    thanks sooooo much dude
    i NEVER wrapped my head around how this works
    now i am crystal clear :)

  • @akanirokingsley3304
    @akanirokingsley3304 10 місяців тому +1

    your explanations resonates with me on a deep level.

    • @DatabaseStar
      @DatabaseStar  10 місяців тому

      This makes me happy. I’m glad the explanations help you!

  • @manojkumar-yc4xq
    @manojkumar-yc4xq 8 місяців тому +2

    What a clean and easy way of explaining the fact. Thank you SIR.

  • @rjjalaparthi545
    @rjjalaparthi545 5 місяців тому +1

    Clear cut explanation, i always had doubt why we need to group by column which we used in select statement when we use aggregate functions in select, now its so clear. Thanks for the help

  • @lexiwhitmore2197
    @lexiwhitmore2197 Рік тому +2

    This was helpful and clear, thank you! I liked your group by question, because I tend to create a question like that when I'm struggling to formulate the correct query.

  • @COOKINGBIRD
    @COOKINGBIRD Рік тому +2

    Your SQL video was exactly what I needed. Thank you for explaining it so clearly. 😄🎬💻🔍

  • @khawar1690
    @khawar1690 9 місяців тому +1

    Very well explained. Aggregated function was helpful to me. Thank you

  • @aciv132
    @aciv132 2 місяці тому +1

    10/10 explanation. Very simple.

    • @DatabaseStar
      @DatabaseStar  2 місяці тому

      Thanks, glad you found it helpful!

  • @thebigcheese1153
    @thebigcheese1153 10 місяців тому +1

    Thanks for actually explaining it.

  • @aashutosh937
    @aashutosh937 2 роки тому +2

    Thank you for explaining it in such a simple way :)

  • @DCh-ks6ug
    @DCh-ks6ug 11 місяців тому +1

    that waaaaas veeeeery helpful thaaaaaank you

  • @nickjoseph2711
    @nickjoseph2711 2 роки тому +1

    Super helpful. First slide's visual really helped...

  • @jatinsharma8353
    @jatinsharma8353 Рік тому

    awesome most easiest explanation. Thanks man

  • @Aliyaaugust
    @Aliyaaugust 8 місяців тому

    Great explanation 💯🤍🤍🤍

  • @higiniofuentes2551
    @higiniofuentes2551 Рік тому

    Thank you for this very useful video!

  • @tsunamio7750
    @tsunamio7750 Рік тому

    Nice video! Your indentation hurts me, but thank you for this video; It is very well presented!

    • @DatabaseStar
      @DatabaseStar  Рік тому

      Thanks! Do you prefer a different style of indentation for SQL code?

  • @dragoneer8756
    @dragoneer8756 Рік тому

    Good to know, most important part was that the field selected should be in the group by clause. THey completely left that out in class

    • @DatabaseStar
      @DatabaseStar  Рік тому

      Glad you liked the video. Can’t believe they left that out of your class!

    • @dragoneer8756
      @dragoneer8756 Рік тому

      @@DatabaseStar It was a very rushed class tbh. Teaching finished at the beginning of November so I'm self-studying for finals😅😅

  • @mustaphaelouahabi9316
    @mustaphaelouahabi9316 Рік тому

    👋 Bravo!
    A very well-explained demo!

    • @DatabaseStar
      @DatabaseStar  Рік тому

      Thanks!

    • @mustaphaelouahabi9316
      @mustaphaelouahabi9316 Рік тому

      @@DatabaseStar....... You're very welcome!
      Can you please make a crash course about "MySQL for Advanced Data Analytics"?

  • @leonsant-jennings7417
    @leonsant-jennings7417 Рік тому

    Cheers boss, I knew I had to use Group By but I didn't fully understand why.

  • @Mike-vj8do
    @Mike-vj8do Рік тому

    real good video, thank you!

  • @mrjump6745
    @mrjump6745 Рік тому

    very detailed. clear. beautiful
    thanks ALOT
    really helpful

  • @bot299i82
    @bot299i82 8 місяців тому +29

    😂 nobody understand group by

    • @DatabaseStar
      @DatabaseStar  8 місяців тому +4

      It can be hard to understand

    • @laeta_ofc
      @laeta_ofc 7 днів тому +1

      To be honest i was really confused because i get it what it does i just dont know how does it influences the answer. Like what the hell😭 And why is it almost the last one??

  • @diamondsandlipgloss
    @diamondsandlipgloss 7 місяців тому +2

    1:18 why do we need the parenthesis around the asterisk in the SELECT FROM statement?

    • @DatabaseStar
      @DatabaseStar  7 місяців тому +1

      Good question. It's because the word COUNT is a function, and functions need to have brackets at the end of the name so they can run.
      Inside the brackets for functions, we specify parameters, such as values or columns to be processed by the function.
      The COUNT function can count columns: for example, COUNT(first_name) counts the number of first_name values that are not NULL.
      The asterisk is a different parameter to the COUNT function, and it means "count the entire row". So, COUNT(*) means count the entire row.
      Hope that answers your question.

    • @diamondsandlipgloss
      @diamondsandlipgloss 7 місяців тому

      @@DatabaseStar got it, SO VERY helpful
      i don't know how i'll remember all of this 🤦🏾‍♀️

  • @csmahi2046
    @csmahi2046 2 дні тому

    Sir can we use order by with sum, count, avg at the end?
    Like....order by sum(*) desc limit 3, plz clarify.

  • @salmaa7810
    @salmaa7810 Рік тому

    very helpful; thank you!

  • @SpringRain23
    @SpringRain23 2 роки тому

    Excellent video !

  • @douaz6905
    @douaz6905 5 місяців тому

    Thank you very much

  • @mostafa2199
    @mostafa2199 2 роки тому

    thanks it really helped

  • @swan_oahu
    @swan_oahu Рік тому

    Thank you 👍

  • @夜逃雨
    @夜逃雨 11 місяців тому

    thank you.

  • @Entertainmentmod
    @Entertainmentmod 3 роки тому

    Very good information

  • @arvindt553
    @arvindt553 Рік тому

    Can you please give an example with two tables that have many to many relationships

  • @vaylx2253
    @vaylx2253 2 роки тому

    Thanks for that.

  • @hfghffggjngyh4754
    @hfghffggjngyh4754 5 місяців тому

    thax

  • @emekatimothyiloba699
    @emekatimothyiloba699 2 роки тому

    Thanks

  • @statesman6379
    @statesman6379 Рік тому

    My only question is if you have 3 columns in the Select Statement with an aggregate function, for example, is it mandatory to always include all 3 columns in the group by clause? And if not, then how do we know which of the 3 columns must be included?

    • @DatabaseStar
      @DatabaseStar  Рік тому

      Good question. Yes, it's mandatory to include all three columns in the Group By clause. If you don't, you'll get an error about columns in the Select not in the Group By (the exact error will depend on the database vendor).
      The only exception is some versions of MySQL allow you to have a mismatch between the Group By and the Select. But you'll get a result that won't be correct, such as showing the first group only but the aggregate function on all rows.

    • @statesman6379
      @statesman6379 Рік тому

      @@DatabaseStar Thanks for the awesome reply! I just subscribed.

  • @mikkii3989
    @mikkii3989 Рік тому

    I honestly gonna die with this language :")

  • @finnnelson5472
    @finnnelson5472 2 роки тому

    🙌

  • @Entertainmentmod
    @Entertainmentmod 3 роки тому

    Can you t sql vedios