WEBVTT

00:07.520 --> 00:08.120
Alrighty.

00:08.150 --> 00:13.520
So let's go ahead and learn about a group by clause in PostgreSQL.

00:14.120 --> 00:14.570
All right.

00:14.570 --> 00:15.740
Let me go ahead and see.

00:15.980 --> 00:20.180
We have these countries and I have these strings.

00:20.180 --> 00:23.690
And each of these students are from different countries.

00:23.690 --> 00:28.820
And now I want to know how many students have come from each of these countries.

00:28.970 --> 00:29.810
Remnants.

00:29.840 --> 00:32.840
China Russia Thailand appeared numerous times.

00:32.870 --> 00:34.220
What I want.

00:34.250 --> 00:39.170
How many of these students that come from each of these countries.

00:39.890 --> 00:42.650
So how can we be able to do that?

00:43.130 --> 00:45.170
So if I say we should do that.

00:45.440 --> 00:46.640
So let me go ahead and see.

00:46.670 --> 00:47.150
All right.

00:47.180 --> 00:49.220
Select all from students.

00:49.220 --> 00:54.860
And uh, in warhead I use the group by clause.

00:54.860 --> 00:58.640
And in order to use that you might go ahead and see.

00:58.700 --> 01:05.310
Let's go ahead and select and uh Country from.

01:07.320 --> 01:08.100
Students.

01:08.100 --> 01:09.210
Then.

01:10.470 --> 01:11.430
Group.

01:14.610 --> 01:17.700
Group by then country.

01:17.850 --> 01:20.100
And then let's go ahead and query.

01:20.130 --> 01:28.350
Then we have this Bangladesh Indonesia Venezuela Cameroon and so on.

01:29.190 --> 01:32.040
So that is more than 24 out of 24.

01:32.070 --> 01:34.170
But one of those group is countries.

01:34.170 --> 01:36.600
What I want to have a count.

01:36.600 --> 01:43.170
That means I want to see Bangladesh number of displays then Indonesia number of distilleries.

01:43.200 --> 01:45.120
How can we be able to do that.

01:45.120 --> 01:53.520
So in order to do that, if you want to use a group by clause, we go ahead and use what is called count.

01:53.520 --> 02:01.200
In order to use count, what you need to do is you go ahead and say select from a select country.

02:01.200 --> 02:07.090
And then you put a comma and then add counts.

02:09.430 --> 02:16.390
So this counts is when we have us to determine how many of these students.

02:16.390 --> 02:18.160
And we're going to count all.

02:18.190 --> 02:20.290
Then we'll go ahead and execute this.

02:20.320 --> 02:22.450
Now we have Bangladesh.

02:22.450 --> 02:24.850
Count is five students.

02:24.880 --> 02:27.490
Indonesia is a one on one.

02:27.520 --> 02:30.730
That is a very large number of people.

02:30.730 --> 02:39.640
And uh, you can see down there, you can still have so many of them and uh, Poland, Somalia one,

02:39.670 --> 02:43.660
Haiti two, Costa Rica three, and so on.

02:44.350 --> 02:50.140
Now we can also go ahead and uh, we have one of the largest right in here as China.

02:50.140 --> 02:50.890
We have one, right.

02:51.040 --> 02:52.180
It's a one.

02:52.360 --> 02:57.190
It's nine people from China, over 101 from Indonesia.

02:57.370 --> 03:04.870
Now you go ahead and, uh, ordered this alphabetically and to order this alphabetically because I've

03:04.870 --> 03:05.950
learned how to do that.

03:05.980 --> 03:07.920
What I need to do is go quiet.

03:07.950 --> 03:11.370
I used the other class and I'm going to say order.

03:12.120 --> 03:13.950
By then.

03:13.980 --> 03:14.880
You will see.

03:17.100 --> 03:18.120
The country.

03:18.210 --> 03:21.990
And then we go ahead and execute this query.

03:22.110 --> 03:33.840
And now we have our Afghanistan six Albania five, America, Samoa one, Argentina 16 and down to the

03:33.840 --> 03:37.110
last one, which is Yemen, and that is six.

03:37.110 --> 03:38.640
Vietnam is 11.

03:39.750 --> 03:40.080
All right.

03:40.140 --> 03:44.310
So this is how we use the group by clause in PostgreSQL.

03:44.310 --> 03:46.890
So go ahead and use that group that check it out.

03:46.890 --> 03:49.980
And you really love what you're doing on the here.

03:50.010 --> 03:51.630
So practice with this.

03:51.660 --> 03:55.980
If you have any question under this Moorhead and use the question and answer section.

03:55.980 --> 03:58.830
And I'm going to get back to you as soon as possible.

03:58.830 --> 04:00.450
So thank you so much.

04:00.450 --> 04:04.020
And I'm going to see you in the next video lecture.
