Having vs Where in MySQL | Beginner MySQL Series

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 ธ.ค. 2024

ความคิดเห็น • 37

  • @malcorub
    @malcorub ปีที่แล้ว +21

    As little as I use HAVING since once you start using CTE's an Temp Tables you can just always filter on the WHERE, this is one of the most common questions that's always asked in SQL job interviews especially if there is some sort of technical test.

    • @echodelta7680
      @echodelta7680 5 หลายเดือนก่อน +5

      In India, questions revolving around WHERE, GROUP BY and HAVING are sort of standard in technical rounds. Difference between WHERE and HAVING is guaranteed to be asked.

  • @BruceBeck-f1n
    @BruceBeck-f1n 7 หลายเดือนก่อน +8

    Short & concise. Just the relevant info. Thank you for working within my attention span!

  • @victorbegnini5754
    @victorbegnini5754 7 หลายเดือนก่อน +3

    Awesome - as usual! Straight to the point. Thanks, Alex!

  • @Cici-z6z
    @Cici-z6z 5 หลายเดือนก่อน +20

    I feel like this was a bit rushed and could benefit from a little more explanation on the difference between HAVING and WHERE, especially since it seems to be a commonly asked technical interview question.

    • @cashimeerkatt1035
      @cashimeerkatt1035 3 หลายเดือนก่อน +11

      In what I read, HAVING is used because it can use aggregate functions, wherein WHERE cannot. Hope it helps!

    • @jean_orgues756
      @jean_orgues756 16 วันที่ผ่านมา

      That's exactly the answer . HAVING is used with aggregate functions and with GROUP BY.

  • @chooselife2388
    @chooselife2388 27 วันที่ผ่านมา

    Thanks for your videos. They're really helping me.

  • @techlab1883
    @techlab1883 ปีที่แล้ว

    Such a great teacher Alex! The way you are able to simplify everything into layman's terms is brilliant. Enjoying these tutorials ❤

  • @IrisFlorentinaA
    @IrisFlorentinaA 7 หลายเดือนก่อน +5

    wow wish i had you as a teacher at uni!

  • @coolboyjustin
    @coolboyjustin 3 หลายเดือนก่อน

    thank you for this bootcamp, very helpful

  • @optionkingrobot
    @optionkingrobot 6 หลายเดือนก่อน +1

    good to come here!!

  • @miraclechijioke1213
    @miraclechijioke1213 10 หลายเดือนก่อน

    Very useful. Thank You

  • @cinthiaramos7325
    @cinthiaramos7325 6 หลายเดือนก่อน +1

    Thanks a lot!

  • @leonmadara3903
    @leonmadara3903 ปีที่แล้ว

    HELPFUL.

  • @bear17293
    @bear17293 ปีที่แล้ว +1

    Is there a difference between this and your sql course on AnalystBuilder?

  • @jooney54
    @jooney54 19 วันที่ผ่านมา

    So i wrote one with the sakila schema using address table. Somebody please let me know if this was a correct use of Having:
    #shows districts that have more that 5 people(or addresses) saved:
    Select district, count(address_id)
    From sakila.address
    Group by district
    Having count(address_id) > 5
    #used address_id as it's unique and entries cannot be null for a row
    Also aggregate functions include avg, max, min count right? Did i miss anything??

  • @andh2627
    @andh2627 ปีที่แล้ว +2

    is this series going to replace whats in your bootcamp series?

  • @macflorek1
    @macflorek1 ปีที่แล้ว +1

    Hi, I'm trying to transition to data analytics from engineering. Apparent obstacle is that i don't have experience in data. I know that I should learn SQL. Is there any certificate that I can do to proove i'm proficient wioth SQL to future employeers? Thanks

    • @pushon10
      @pushon10 ปีที่แล้ว +2

      google data analytics certification and azure data fundamentals

    • @macflorek1
      @macflorek1 ปีที่แล้ว

      @@pushon10 Thanks. Any other certificate that is SQL-specific?

    • @pushon10
      @pushon10 ปีที่แล้ว

      @@macflorek1 idk

  • @clarke6814
    @clarke6814 13 วันที่ผ่านมา

    ✅complete

  • @AR-tx1gn
    @AR-tx1gn 4 หลายเดือนก่อน +1

    I am following along but not actually learning, because I'm finding myself just typing what you're typing and I'm not fully thinking through what you're actually doing...

    • @Toyahan43
      @Toyahan43 4 หลายเดือนก่อน +1

      same :/

    • @cashimeerkatt1035
      @cashimeerkatt1035 3 หลายเดือนก่อน +3

      Same! But what I found helpful is that you can watch the video first and take little notes about what clauses he's using in the vid, etc. then you can open MySQL and try to redo what he did without looking at the video. This worked for me so I hope it helps :D

  • @seanmclaughlin7415
    @seanmclaughlin7415 ปีที่แล้ว

    Alex or anybody here, I need help! Anybody have issues with their sQL management server studio 19 not automatically populating the server name and password in order to connect with the server? Am I missing something here? Can’t get started with Alex’s boot camp until I figure this out. Thank you for any input. It will be greatly appreciated! Maybe it is my computer?

  • @wilsonman8661
    @wilsonman8661 ปีที่แล้ว +2

    First. 👀

    • @AlexTheAnalyst
      @AlexTheAnalyst  ปีที่แล้ว +1

      to my heart

    • @wilsonman8661
      @wilsonman8661 ปีที่แล้ว +3

      @@AlexTheAnalyst Take that, Alex's wife and kids.

  • @knygrs
    @knygrs หลายเดือนก่อน

    done

  • @MarianneHMiettinen
    @MarianneHMiettinen 3 หลายเดือนก่อน

    Interestingly, THIS select gender, avg(age)
    from parks_and_recreation.employee_demographics
    where age > 40
    group by gender
    ;
    gives:
    Female 45.0000
    Male 52.0000

    • @engrwehelie9641
      @engrwehelie9641 หลายเดือนก่อน

      your Query is saying "give the Average age of those above 40 while grouping by their sex".
      -------------------
      Female 44
      Female 46
      Male 61
      Male 43

    • @JeOwLearning
      @JeOwLearning หลายเดือนก่อน

      SELECT gender, AVG(age)
      FROM parks_and_recreation.employee_demographics
      GROUP BY gender
      HAVING AVG(age) > 40
      ;
      VS
      SELECT gender, AVG(age)
      FROM parks_and_recreation.employee_demographics
      WHERE age > 40
      GROUP BY gender;
      Key Differences:
      When Filtering Happens:
      WHERE clause: Filters individual rows before grouping. Only rows that meet the condition (age > 40) are included in the calculations.
      HAVING clause: Filters after grouping. The query groups all the data first, calculates the averages, and then filters the grouped results based on those averages.
      Impact on Results:
      WHERE: This query only considers employees older than 40 when calculating the average age. Both genders appear because their filtered average age is over 40.
      HAVING: This query calculates the average age for all employees first, then filters based on the result. In the example, only the male group’s average age is greater than 40, so only males appear in the result.

    • @jooney54
      @jooney54 19 วันที่ผ่านมา

      Not sure if I am correct but that's because where is using just the age column and not the some aggregate function as the parameter.
      From what I understood aggregate functions run only after the Group by statement so just the where age >40 should be fine.