Thank you for telling us that even when you first learned this it was complex, because holy cow! I cannot wrap my head around this. I can kind of grasp whats going on, but I think you know the confusion that goes through a noob's mind. Thank you for your tutorials! I plan on watching many more of your videos.
WOW! the way you explained that is like first doing a table to then going and making a query from that table was a breakthrough for my understanding of the concept. I really admire people who can transform concepts into more digestible material. Thanks
Just started a Business Systems Analyst entry level position that uses SQL everyday and this video has been so helpful! You explained it better than the corporate instructor, Khan Academy and my Udemy course! THANK YOU!!!!
Excellent explanation, these sub queries got me messed up but this video helped. Your great and explaining and hoping you succeed with your channel, you seem like a genuine dude.
Very helpful, some key explanation that made it "click" with me. And most of all, I like that you confess to your struggle at the beginning, beacause I have my though times right now....
hope you would keep on making SQL tutorials (or other programming language). you help me a lot in my review for my assessment. you have explained each topic very well! I'm learning a lot from you.
overwhelmed?! tuh... i am terrified! i came to you, from my online course, for some type of clarity. what did I get you might ask. HUMBLED! tfs this video anyway, I'm hopeful I will find some gems on your channel. -your new (maybe in over her head) subscriber
This was very helpful. It saved me a lot of time. I understood it the first viewing and was able to apply the concepts with ease and complete my homework on time. Thank you, you do an excellent job. I will come back for future questions in SQL.
I didn't understand the concept one bit and I didn't understand why we should use them when I was in the university, but I understand now lol. Thanks for the tutorial. It's simple, yet really helpful for me
Hi there, I really liked the explanation, just a suggestion if you would give a very quick overview of the heads of the dataset so that it is easier to comprehend more how the query/subquery is extracting the data.
I am here wondering if another way to write the first example with freight as SELECT AVG(Freight), customer_id FROM orders GROUP BY customer_id Would give same result as the Subquery in the first example?
Question regarding the first example; could you not achieve the same result without a subquery by just adding avg(freight) as avg to the original select statement?
Hi, may you help me with this if you don’t mind? how to exclude from the results similar values of the same row from two columns that are being compare. For example, in the same row, column 1 is 4567 and column 2 can be 4567 or 4568 or 4566. Since numbers are similar, the idea is to exclude that row if the number in column 2 is the same as column 1 or the number is plus or minus 1 of column 1’s number. If the column 1 is 4564 and column 2 is 4566, it would not be excluded since the number are not similar. I am trying to account for te value in each row of the column that has been rounded to the nearest whole number.
It seems the subquery in the where clause is easiest to understand. SQ in the select statement is probably used to compare as it's gong to give only a single value irrespective of all the records. And finally SQ in the from can be used to create a temp table with aggregates; which will be used by outer query to do further aggregates.
Beginner here with some experience. I don't get the group by 1 , 2. I'm used to grouping by the field name. Is Group BY 1, 2 the same as typing Group BY customerID, shipcountry ?
thanks for the explanations. Why wouldn't you be able to take the average directly instead of needing to first subquery? Also, in the first subquery example, why do you need the subquery instead of writing SELECT AVG(freight)?
Like how do WE make a Query of two cities in a STATION table with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.
When doing a sub query (inner SELECT) and referencing it from the outer SELECT statement can I use a WHERE clause in the outer SELECT Statement or does it need to be in the Inner SELECT Statement? Similarly once I have established my inner SeELECT statement can I then use those columns in a CASE Statement?
Subquery in the where clause I get, no problem. Example for subquery in the select statement made no sense to me, why repeat that same figure for every row? Sub query in the from clause...gonna need more practice. Also, what's the difference between a subquery in the from clause and a CTE?
Hi How's going ? Thank you for the video! I have a question about "inner query gets executed first", does it only apply to the subquery in FROM statement or no matter in SELECT/ FROM / Where statement ? Thank you very much!
@@summer9380 My guess is referring to the columns in the select. As group be the first attribute then group by the second (cant remember the exact attribute names).
The idea that a subquery in a FROM statement creates a table and starting the query process from there was a real lightbulb moment - thank you
Finally, a break through. Finally, someone who explains the use of sub queries well.
CANNOT EXPLAIN ENOUGH HOW MUCH YOU SAVED MY LIFE.
Spending my Christmas binge watching your SQL tutorials haha so helpful. Thank you!!!!
Haha, sounds like a good Christmas to me!
Thank you for telling us that even when you first learned this it was complex, because holy cow! I cannot wrap my head around this. I can kind of grasp whats going on, but I think you know the confusion that goes through a noob's mind. Thank you for your tutorials! I plan on watching many more of your videos.
I am getting ready for an internship using SQL as a data analyst and this made a ton of sense, thanks! I will be subscribing
did you get the internship? just curious lol
WOW! the way you explained that is like first doing a table to then going and making a query from that table was a breakthrough for my understanding of the concept. I really admire people who can transform concepts into more digestible material. Thanks
This is really helpful; more so than my online course! I look forward to watching more of your videos. Thank you!
Just started a Business Systems Analyst entry level position that uses SQL everyday and this video has been so helpful! You explained it better than the corporate instructor, Khan Academy and my Udemy course! THANK YOU!!!!
Your SQL knowledge is admirable.
super helpful and you explain stuff in a way where you don't rush through it but also don't take ages on it.
So easy to understand without broken English. Keep them coming!
I bought a course on Udemy, you solve like 10 doubts I had in just 1 video
Excellent explanation, these sub queries got me messed up but this video helped. Your great and explaining and hoping you succeed with your channel, you seem like a genuine dude.
Thanks a lot for the kind words, means a lot!
Absolutely amazing explanation and you give hope that you said it took you a while, now look at you.
Very helpful, some key explanation that made it "click" with me. And most of all, I like that you confess to your struggle at the beginning, beacause I have my though times right now....
Where the heck have you been? You’re the only useful person on RUclips!
hope you would keep on making SQL tutorials (or other programming language). you help me a lot in my review for my assessment. you have explained each topic very well! I'm learning a lot from you.
Really great explanations. Easy to follow and perfect variety. Very much appreciate you posting these tutorials, they're beyond helpful. Thanks!
Thank you for explaining it the way you did, it just clicked for me. Great stuff! Keep up the good videos.
Great video man!
The best explanation of sub queries that I found!
This is helping me a lot because I'm starting with a course of T-SQL
A great, and much needed take on this subject.
What does the 1,2 mean in the Group By 1,2?
Really good explanation. I will be glad to share this with developers who write "expensive" queries with complex join statements.😀
overwhelmed?! tuh... i am terrified!
i came to you, from my online course, for some type of clarity.
what did I get you might ask. HUMBLED!
tfs this video anyway, I'm hopeful I will find some gems on your channel.
-your new (maybe in over her head) subscriber
There are also subqueries in join. It's hard to find a material as good as this. Leaving a like and comment to support your channel.
This was very helpful. It saved me a lot of time. I understood it the first viewing and was able to apply the concepts with ease and complete my homework on time. Thank you, you do an excellent job. I will come back for future questions in SQL.
Thank you for sharing, I feel stupid not understanding, but you kind of make it clearer
Actually for me this makes amazing sense. Thanks for the tutorial.
Thank you, a great explanation and examples for subqueries.
I didn't understand the concept one bit and I didn't understand why we should use them when I was in the university, but I understand now lol. Thanks for the tutorial. It's simple, yet really helpful for me
I like how you explain, keep up the good work.
Thanks for the tutorials, you have being of great help on this journey...Keep them coming
Awesome explanation. Thank you very much. I was completely lost on subqueries.
You sir are such a great teacher. Thank you
you just helped me through my project in SQL, thankss a lot!
And The search ends here.... Perfect 💯
great videos! Its soo much easier too understand when watching your tutorials! Please do more advanced videos with window functions etc.
Thank you! You look so positive and warm person :)
This is exactly what I was looking for - thank you for sharing!
Does the internal table have to be the same as the outer table? "orders" in your example.
All your videos are very helpful and well explained! Helps me a lot in understanding SQL better. Are you planning on doing any more on SQL soon?
Brilliant explanation The online course I took had me lost at this part.
Simple and direct. Just what I was needed.
Great video! Thank you so much for bringing a clear explanation of this topic. I look forward to viewing your other videos.
This is so helpful! Thank you!! Rec: time stamps for each example
I love the way you teach. You are clear and concise. How long have you been writing SQL?
Thank you for this brilliant video. Please upload more :) :).
Thank you for summing up subquery. Thank you.
Average number of orders per customer is a bit ambiguous as this could mean per specific customer instead of per one general customer.
Hi there, I really liked the explanation, just a suggestion if you would give a very quick overview of the heads of the dataset so that it is easier to comprehend more how the query/subquery is extracting the data.
This is an excellent video. Thank you!
I am here wondering if another way to write the first example with freight as
SELECT AVG(Freight), customer_id
FROM orders
GROUP BY customer_id
Would give same result as the Subquery in the first example?
Question regarding the first example; could you not achieve the same result without a subquery by just adding avg(freight) as avg to the original select statement?
Quick question: what is the group by 1,2 doing? is that just ordering them by the order in which they columns were entered in the select statement?
Hi, may you help me with this if you don’t mind?
how to exclude from the results similar values of the same row from two columns that are being compare. For example, in the same row, column 1 is 4567 and column 2 can be 4567 or 4568 or 4566. Since numbers are similar, the idea is to exclude that row if the number in column 2 is the same as column 1 or the number is plus or minus 1 of column 1’s number.
If the column 1 is 4564 and column 2 is 4566, it would not be excluded since the number are not similar.
I am trying to account for te value in each row of the column that has been rounded to the nearest whole number.
Well explained thanks a lot finally was able to get a better grasp of Sub Queries
Great video, very comprehensive!
how can i get a total count of rows then find the average of it using a date range?
Great video easy to understand
It seems the subquery in the where clause is easiest to understand. SQ in the select statement is probably used to compare as it's gong to give only a single value irrespective of all the records. And finally SQ in the from can be used to create a temp table with aggregates; which will be used by outer query to do further aggregates.
Beginner here with some experience. I don't get the group by 1 , 2. I'm used to grouping by the field name. Is Group BY 1, 2 the same as typing Group BY customerID, shipcountry ?
thanks for the explanations. Why wouldn't you be able to take the average directly instead of needing to first subquery? Also, in the first subquery example, why do you need the subquery instead of writing SELECT AVG(freight)?
Thanks, great explanation!
Amazing Explanation Thank you 🙌
Can we use
SELECT * FROM (SELECT * FROM USERS) like this ?
wait so why did you use select for avg the first time but the second time you used it without select. Is there a rule?
Lovely. Thanls a lot for this great share 👌🙂
Great explanation. Thank you :)
explained very well. thank you
Like how do WE make a Query of two cities in a STATION table with the shortest and longest CITY names, as well as their respective lengths (i.e.: number of characters in the name). If there is more than one smallest or largest city, choose the one that comes first when ordered alphabetically.
I don't get it why need to use subqueries for the select clause average freight. Why can't just use avg(frieght)? Arent that the same thing?
you are a champion thanks a lot..(im buying your book also!!!)
When doing a sub query (inner SELECT) and referencing it from the outer SELECT statement can I use a WHERE clause in the outer SELECT Statement or does it need to be in the Inner SELECT Statement? Similarly once I have established my inner SeELECT statement can I then use those columns in a CASE Statement?
That was great Explaination.
Thanks for this sql series
it should be a crime that universities get away with charging 50k of tuition for a shittier version of the stuff we learn for free. Really helpful!
You’re a real G
What about inside joins( Select........ )?
Also, where to find other good sources to understand subquery ?
What do you mean by "group by 1", and "group by 1,2"
Thank you for your effort, keep moving
Can i use a subquery from two tables?
loved this!!!
Thanks helped me out heaps!
Subquery in the where clause I get, no problem. Example for subquery in the select statement made no sense to me, why repeat that same figure for every row? Sub query in the from clause...gonna need more practice. Also, what's the difference between a subquery in the from clause and a CTE?
Is that num_orders number of orders or order number?
Very helpful - thank you !!
nice job!
Great explanation! Do you have a video for Correlated Subquery as well? It is super confusing
1:47 how is that more useful than "avg freight per customer" :
SELECT customerid, avg(freight)
FROM orders
GROUP BY customerid
Awesome vid! thanks bud :)
How to find sum of the sum using dub query
where is your ER diagram? or where are you getting the info to make your queries
Hi How's going ? Thank you for the video!
I have a question about "inner query gets executed first", does it only apply to the subquery in FROM statement or no matter in SELECT/ FROM / Where statement ?
Thank you very much!
Dude this was great.
Hi! What program are you using to code? thank you! and what DBMS are u using
Great explanation! What do the numbers 1 and 2 represent in the command "GROUP BY 1, 2" ?
what i wondered too
@@summer9380 My guess is referring to the columns in the select. As group be the first attribute then group by the second (cant remember the exact attribute names).
very helpful video. I just have a question, which one is better(most "performant") , doing a subquery or a join?
Great Thank you. How can i use joins with it?
I hope you don't mind me asking for a help with my sql code..how can I reach you?
Thank you bro man 💥