Alrighty.
So let's go ahead and learn about a group by clause in PostgreSQL.
All right.
Let me go ahead and see.
We have these countries and I have these strings.
And each of these students are from different countries.
And now I want to know how many students have come from each of these countries.
Remnants.
China Russia Thailand appeared numerous times.
What I want.
How many of these students that come from each of these countries.
So how can we be able to do that?
So if I say we should do that.
So let me go ahead and see.
All right.
Select all from students.
And uh, in warhead I use the group by clause.
And in order to use that you might go ahead and see.
Let's go ahead and select and uh Country from.
Students.
Then.
Group.
Group by then country.
And then let's go ahead and query.
Then we have this Bangladesh Indonesia Venezuela Cameroon and so on.
So that is more than 24 out of 24.
But one of those group is countries.
What I want to have a count.
That means I want to see Bangladesh number of displays then Indonesia number of distilleries.
How can we be able to do that.
So in order to do that, if you want to use a group by clause, we go ahead and use what is called count.
In order to use count, what you need to do is you go ahead and say select from a select country.
And then you put a comma and then add counts.
So this counts is when we have us to determine how many of these students.
And we're going to count all.
Then we'll go ahead and execute this.
Now we have Bangladesh.
Count is five students.
Indonesia is a one on one.
That is a very large number of people.
And uh, you can see down there, you can still have so many of them and uh, Poland, Somalia one,
Haiti two, Costa Rica three, and so on.
Now we can also go ahead and uh, we have one of the largest right in here as China.
We have one, right.
It's a one.
It's nine people from China, over 101 from Indonesia.
Now you go ahead and, uh, ordered this alphabetically and to order this alphabetically because I've
learned how to do that.
What I need to do is go quiet.
I used the other class and I'm going to say order.
By then.
You will see.
The country.
And then we go ahead and execute this query.
And now we have our Afghanistan six Albania five, America, Samoa one, Argentina 16 and down to the
last one, which is Yemen, and that is six.
Vietnam is 11.
All right.
So this is how we use the group by clause in PostgreSQL.
So go ahead and use that group that check it out.
And you really love what you're doing on the here.
So practice with this.
If you have any question under this Moorhead and use the question and answer section.
And I'm going to get back to you as soon as possible.
So thank you so much.
And I'm going to see you in the next video lecture.