Subqueries in MySQL | Intermediate MySQL

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

КОМЕНТАРІ • 68

  • @ATCSABChaitra
    @ATCSABChaitra 11 місяців тому +8

    U are the best mentor and guide

  • @BruceBeck-f1n
    @BruceBeck-f1n 8 місяців тому +14

    A LOT going on in this lesson. Alex did a nice job of walking me through subqueries in MySQL. As the previous commenter suggests, I need MORE practice to really get these concepts embedded into the "gray matter" inside my head. At the very least, I intend to re-watch this video a couple of times without trying to keep up typing code, etc. I am getting a great deal of value from all of Alex's work. Thanks! 😎

    • @marilowe.lifestyle
      @marilowe.lifestyle 7 місяців тому

      same, it will take a few note taking as well with reasons on why we use each function. by this video i knew I shouldnt just follow along with the coding but understanding when to use the code and how to use it.

  • @SophieAbrams-e3b
    @SophieAbrams-e3b 3 місяці тому +12

    Definitely the first video I started having some difficulty fully understanding. Any other resources you suggest looking at?

    • @dname1802
      @dname1802 Місяць тому

      Just a youtube search for a subqueries in SQL will give many options. Check out one or two and you'll get the concept. And chatGPT is a great source for asking specifics.

  • @brazehvic8896
    @brazehvic8896 11 місяців тому +18

    Great explanations and options. Would have been better if you included the data file link to self-practice. Remember the best way to learn is learning by doing!

    • @bjrnolavskaurum3854
      @bjrnolavskaurum3854 11 місяців тому +1

      True. Having the dataset to work on would be way better than watching someone else perform tasks. Hopefully Alex reads your comment.

    • @cjbrown3396
      @cjbrown3396 9 місяців тому +18

      You have to follow his course along the way. Alex used the file in the beginning as the teaching series.

  • @Thisisrealfia
    @Thisisrealfia 11 місяців тому +2

    Just when I needed to understand more about 'subqueries', this video came up. Thanks, Alex!

  • @delhiwala8511
    @delhiwala8511 11 місяців тому +4

    Hello Sir Ji Love You Hogaya From India 🇮🇳

  • @WilnerSumagingsing
    @WilnerSumagingsing 4 місяці тому +2

    Subquery can be denote as a virtual table. It can be use also with JOIN clause. Thanks

  • @kushalsaha6299
    @kushalsaha6299 15 днів тому

    Timestamp- 3:02
    What if I want to see the salary also with these other informations? I can't return more than 1 column in operand. So how to find salary?

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

    Such lucid explanation gives me confidence to become successful data analyst, May our Good Lord Sheperd bless you with good health, wealth and eternal happiness! ✝

  • @nickl3135
    @nickl3135 11 місяців тому +1

    Loving this series ! Thanks so much

  • @irdcs
    @irdcs 6 місяців тому +2

    Honestly it was too confusing to me (I'm starting from scratch) so I'm gonna have to learn this somewhere before I continue with the course. So frustrating 😅.

  • @colleenoleary2966
    @colleenoleary2966 6 місяців тому

    At 2: 35, when you get the results of the subquery...I'm not. I'm getting the results of the full query b/c I've been hitting the bolt w/ the I on it, instead of the bolt by itself...which is what you're doing in the video, but not mentioning which bolt you're hitting and why.
    Please specify which one you're hitting to get the results you're getting.
    Also, I don't understand WHY you would do what you did from 8:00 on.
    What's the use case for it?

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

      If you hit the bolt with I, it’s gonna run the code where your cursor is.
      If you want to run all the codes or want to select some lines and just get the output of them, you should click on the bolt by itself. If you select some lines and then click the bolt with I, it runs the whole code not just your selection part.
      In 2:35 Alex select those lines so he clicked on the bolt by itself to only get the result of those lines.

  • @sadooya1017
    @sadooya1017 4 місяці тому

    can someone explain me why exactly do we need to add the multiple Tabs before adding the another query 1:50

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

      The tabs are there just for the readability. It makes the code easier to read and understand. You could write the code in one line but it would be hard to find mistakes and wouldn't look good.

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

      Thank you, i understand it better now ​@Toyahan43

  • @VkTolani
    @VkTolani 6 місяців тому

    we can use 3:50 self join here as well?

  • @atzirimendozagtz9787
    @atzirimendozagtz9787 8 місяців тому +1

    I don't know if I missed it but does where you insert the subquery make a difference? If so, what are they so that I can better understand when I run into the need to use a subquery.

  • @Evgeny-p8s
    @Evgeny-p8s 2 місяці тому

    Excellent explanation, thanks

  • @chubz155
    @chubz155 11 місяців тому +1

    I am currently learning sql and I am watching your videos especially the bootcamp ones. I already finished the videos for sql, is there any platform/s you can recommend to practice what I learned from the videos? I am kind of lost on how to practice these learnings. Thank you!

    • @rukayatogundipe5779
      @rukayatogundipe5779 11 місяців тому +4

      You can practice on analyst builder or hackerrank

    • @chubz155
      @chubz155 11 місяців тому

      Thank you very much
      @@rukayatogundipe5779

    • @HopeOverDebt
      @HopeOverDebt 3 місяці тому +1

      Hacker rank and w3schools are perfect to practice what we learn from bootcamp☺

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

    ALEX!!! Awesome guide!! This video is very easy to understand for beginners which i appreciate. Just a quick question on the aggregate function AVG in the subquiery, Why doesn't it require a GROUP BY statement?

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

      The order of operations on the back end causes a syntax error I believe

  • @raphaelmarkd
    @raphaelmarkd 25 днів тому

    Thank you Alex!

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

    What is the purpose of the later half of the subquery?

  • @RubaShu
    @RubaShu 8 місяців тому +1

    Thanks alex for the easy explanation.. just a question, when you wanted to compare the salaries to avg salary, we also can use Partition by instead of s subquery right?

    • @MoustafaElhagri-qx5db
      @MoustafaElhagri-qx5db 7 місяців тому +1

      I thought of that in the first glance as well, but when you think about it you will find that "Partition by" will get you the average salary based on a criteria for example "Gender" but not the average of all the records. If you get another look at, let me know.

    • @RubaShu
      @RubaShu 6 місяців тому +1

      @@MoustafaElhagri-qx5db Yes 100%! after a second look turned out you're right.. but a window function without any partition would do the same as the subquery? ( over() ) i just tried it and it worked

    • @MoustafaElhagri-qx5db
      @MoustafaElhagri-qx5db 6 місяців тому +1

      @@RubaShu I tried your way and it actually works. That was nice, thanks!

  • @bsarath438
    @bsarath438 6 місяців тому

    please provide dataset it really helps to practice

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

      he provided the dataset at the beginning of the series

  • @chooselife2388
    @chooselife2388 Місяць тому

    I'm having trouble understanding this one.
    "WHERE dept_id = 1"
    Why does it return 1,3,4,5,6,12 ?
    TIA

    • @georgia_edits23
      @georgia_edits23 Місяць тому

      1,3,4,5,6,12 are all in the column called employee_id and their dept_id is = 1

    • @Glaivee
      @Glaivee 14 днів тому

      Haha it makes me confuse as well because dept _id coloumn didn't show up, but then i realize that was employee id not dept id

  • @paragupmanyu2891
    @paragupmanyu2891 3 місяці тому

    I don't understand why we haven't used bonus condition in same case statement

    • @FGC_Amu
      @FGC_Amu 3 місяці тому

      I asked myself that question as well!. Its because Ben Wyatt already has a salary > 50000. So technically he is getting a 7% and a 10% bonus!. He only gets a 10% bonus since he is in the FINANCE DEPARTMENT. Maybe its a flaw in the example or a misinterpretation I dont know. So thats why you add another CASE statement otherwise it counts it as >50000 and dept_id 6.

  •  6 місяців тому

    You are a great tutor

  • @FGC_Amu
    @FGC_Amu 3 місяці тому

    I have a question, is it not better to use JOINS instead of subqueries?. From what I understand so far.

    • @marcel-andrehille7064
      @marcel-andrehille7064 3 місяці тому

      As far as I understand it, yes. A subquery seems to be executed recursively. Please correct, if I am mistaken. But in the event of being executed recursively, there will be a tremendous performance impact on large data sets

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

    thankyou for the video!

  • @rajkumarrajan8059
    @rajkumarrajan8059 11 місяців тому +2

    Great!!!

  • @emmanuelamukamara4931
    @emmanuelamukamara4931 11 місяців тому +1

    Great guy

  • @syedfarhaan1998
    @syedfarhaan1998 6 місяців тому

    Thank you sir 💟

  • @maclaudeamumbwe2663
    @maclaudeamumbwe2663 6 місяців тому +2

    Lord, subqueries was tough grasp

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

    Thank you so much :D

  • @Kikkerv11
    @Kikkerv11 6 місяців тому

    CTEs are so much more straightforward.

  • @k.chriscaldwell4141
    @k.chriscaldwell4141 2 місяці тому

    Thank you.

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

    Hello Alex I couldn't download my SQL anyone help me please

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

    Hiii im getting zero in subquries

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

      Alex please respond

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

      9.14 sec the answer which was getting for you not getting same output for me i have type same thing what ew have teach in this video please guide me alex

    • @chinsinang8887
      @chinsinang8887 6 місяців тому

      @@karimullasyed3695 Hi, you might want to paste your query and output here for others to advice.

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

      you should use AS in the max(age) subquery

  • @sailikulkarni6065
    @sailikulkarni6065 4 місяці тому

    where can i practice SQL section wise?

  • @paulperez2005
    @paulperez2005 28 днів тому

    Why could you not have been my teacher in uni huh?

  • @marchosias2071
    @marchosias2071 Місяць тому

    i fried my brain trying to do subquery within subquery within a query but i managed to do it in the end🤓🤕

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

    select salary,(select avg(salary) from employee_salary
    ) avgSalary,
    case
    when salary>avgSalary then 'This employee is earning good'
    end as label
    from employee_salary ;
    when executing this code it says there is no column as avgSalary while I renamed the output coming from subquery as avgSalary, can we not use alias while comparing it with original column?

    • @NK-qb4bp
      @NK-qb4bp 7 місяців тому

      u shouldnt use case statement in the presence of subquery

  • @clarke6814
    @clarke6814 Місяць тому

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

    done. a bit confusing. i need to look up to other youtube video for better and simple explanation