WEBVTT

00:08.000 --> 00:10.880
How coming back again to another video lecture and PostgreSQL.

00:10.880 --> 00:13.400
And let's go ahead and learn order by clause.

00:13.460 --> 00:21.560
So the order by clause helps us to actually, uh, implement things and ascending or descending order.

00:21.680 --> 00:29.060
So if we want to, if we want to work on this and you want to sort your data set based in ascending

00:29.090 --> 00:44.690
order, that is going to start from A, B, C, d, and the the key word for this is ascending ASC.

00:44.990 --> 00:59.240
If we want to do that in descending order, that should be from z y uh x w and the the keyword is this.

00:59.510 --> 01:02.720
So this is a cure for descending on the curve.

01:02.720 --> 01:04.100
Ascending is this.

01:04.850 --> 01:15.560
Now, if I want to sort out the students, uh, data, all I need to do is I can really go over here

01:15.560 --> 01:18.980
and do that, or I can go right in here and set it.

01:19.010 --> 01:21.680
But I think this actually helps us to view it.

01:21.710 --> 01:22.280
Beautiful.

01:22.280 --> 01:23.090
Right in here.

01:23.090 --> 01:27.560
So whatever we do here, you can actually do that on the SQL.

01:27.560 --> 01:30.290
So we can always do the SQL shell to do that.

01:30.320 --> 01:31.340
Or you come over here.

01:31.400 --> 01:37.550
Now let's go ahead and see I want to sort all from students.

01:37.550 --> 01:41.900
And then I'm going to see sort all.

01:41.900 --> 01:44.390
And then I'm going to include the order by clause.

01:44.390 --> 01:53.600
So when I say order by and then I'm going to sort in the first name, last name, email, gender ID

01:53.630 --> 01:55.190
or any one of them.

01:55.190 --> 02:00.620
So I'm going to say maybe the first name or say first underscore name.

02:00.860 --> 02:01.490
Right.

02:01.490 --> 02:09.800
And um, I'm going to sort that in ascending order right here.

02:09.800 --> 02:13.310
Semicolon at the end, at least coherent execute this query.

02:14.660 --> 02:16.520
So I'm going to launch this.

02:16.550 --> 02:21.230
Now you can see that I have this data from the first name.

02:21.230 --> 02:28.520
And if you look at the status ID it is no longer alphabetically arranged very well because it's sorted

02:28.520 --> 02:40.040
this based on the ascending order starting from up and moved down to B and C, and then to E, and then

02:40.070 --> 02:44.750
if you scroll this down to the last this is Z.

02:44.750 --> 02:51.590
So the reason why I use the pgadmin is that it is more easier for me to view, and for us to make this

02:51.590 --> 02:58.250
spot on your SQL, go ahead and implement this and you're going to get exactly the same results.

02:58.370 --> 03:05.090
So if you want to do this sorted by, uh, let me say Country.

03:05.870 --> 03:06.740
So.

03:06.770 --> 03:09.740
And this over here is country.

03:09.740 --> 03:17.840
And if this is the cutest, we're going to see the standard from the workforce from Afghanistan to Albania

03:17.990 --> 03:19.910
and so on.

03:19.910 --> 03:27.650
And if you scroll this down you're going to see that Venezuela, Vietnam, Yemen is the last.

03:27.890 --> 03:31.220
So this is by country.

03:31.730 --> 03:41.330
Now if you want to sort out that by student ID or email, let's go ahead and sort this by email.

03:41.330 --> 03:50.180
So if I go ahead and want to say email and if I run this and hit check the email and you can see that

03:50.180 --> 03:57.650
actually started from a and then move down and uh, it's going to check it out.

03:57.650 --> 04:00.350
So they know is the last one.

04:01.070 --> 04:04.430
Now we have done this on the ascending order.

04:04.460 --> 04:09.220
So what if we want to sort out this email on descending order.

04:09.220 --> 04:13.720
So go ahead and say this right in the Kuwait desk.

04:13.720 --> 04:15.280
And this is the cutest query.

04:15.280 --> 04:22.030
And you can see that they know which starter previously or which was the last is now the first.

04:22.030 --> 04:24.520
And they screw this down.

04:24.550 --> 04:29.350
Remember we have 30% to be null and start from the descending.

04:29.350 --> 04:34.660
That means z is the very first one and y and so on.

04:34.690 --> 04:42.610
And likewise, if we go ahead and uh see first underscore name or last underscore name and go ahead

04:42.610 --> 04:44.590
and check it, check the first name.

04:44.590 --> 04:48.370
And they have Zorah, Zuri and the Zedekiah.

04:48.490 --> 04:51.190
And that is the starting point.

04:51.310 --> 04:55.720
So descent is applicable to last name the square head and check the last name.

04:55.720 --> 04:57.310
Last underscore name.

04:57.340 --> 04:58.360
And let's check it out.

04:58.390 --> 05:00.310
So this is the last name.

05:01.000 --> 05:06.010
And the same is applicable to country or any one of them.

05:06.160 --> 05:06.910
We see.

05:08.110 --> 05:10.390
country and check it out.

05:11.830 --> 05:12.610
Yummy.

05:12.700 --> 05:15.100
Now one of the Imro dates.

05:15.130 --> 05:21.460
Now let's go ahead and check out the Imro dates in real underscore dates.

05:21.460 --> 05:23.320
And let's go ahead and check it out.

05:23.320 --> 05:25.480
And they are straight from the 2015.

05:25.510 --> 05:27.670
The last date to check it out.

05:27.700 --> 05:32.290
You can see 4050 to 2049.

05:32.470 --> 05:33.670
Hope that is cool.

05:33.700 --> 05:37.030
So that is a way the order by clause actually works.

05:37.030 --> 05:41.080
So you sort out these either in ascending or descending order.

05:41.080 --> 05:44.740
And whatever you do here you can actually do that right in here.

05:44.890 --> 05:45.550
Okay.

05:45.580 --> 05:47.800
And that we actually work at fine.

05:47.800 --> 05:49.810
So go ahead and practice with these.

05:49.840 --> 05:50.560
Check it out.

05:50.560 --> 05:54.850
And if you have any question on that is go ahead and use the question and answer section.

05:54.850 --> 05:57.460
And I'm going to get back to you as soon as possible.

05:57.490 --> 05:58.510
Thank you so much.

05:58.510 --> 06:01.840
And I'm going to see you in the next video lecture.
