How coming back again to another video lecture and PostgreSQL.
And let's go ahead and learn order by clause.
So the order by clause helps us to actually, uh, implement things and ascending or descending order.
So if we want to, if we want to work on this and you want to sort your data set based in ascending
order, that is going to start from A, B, C, d, and the the key word for this is ascending ASC.
If we want to do that in descending order, that should be from z y uh x w and the the keyword is this.
So this is a cure for descending on the curve.
Ascending is this.
Now, if I want to sort out the students, uh, data, all I need to do is I can really go over here
and do that, or I can go right in here and set it.
But I think this actually helps us to view it.
Beautiful.
Right in here.
So whatever we do here, you can actually do that on the SQL.
So we can always do the SQL shell to do that.
Or you come over here.
Now let's go ahead and see I want to sort all from students.
And then I'm going to see sort all.
And then I'm going to include the order by clause.
So when I say order by and then I'm going to sort in the first name, last name, email, gender ID
or any one of them.
So I'm going to say maybe the first name or say first underscore name.
Right.
And um, I'm going to sort that in ascending order right here.
Semicolon at the end, at least coherent execute this query.
So I'm going to launch this.
Now you can see that I have this data from the first name.
And if you look at the status ID it is no longer alphabetically arranged very well because it's sorted
this based on the ascending order starting from up and moved down to B and C, and then to E, and then
if you scroll this down to the last this is Z.
So the reason why I use the pgadmin is that it is more easier for me to view, and for us to make this
spot on your SQL, go ahead and implement this and you're going to get exactly the same results.
So if you want to do this sorted by, uh, let me say Country.
So.
And this over here is country.
And if this is the cutest, we're going to see the standard from the workforce from Afghanistan to Albania
and so on.
And if you scroll this down you're going to see that Venezuela, Vietnam, Yemen is the last.
So this is by country.
Now if you want to sort out that by student ID or email, let's go ahead and sort this by email.
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
actually started from a and then move down and uh, it's going to check it out.
So they know is the last one.
Now we have done this on the ascending order.
So what if we want to sort out this email on descending order.
So go ahead and say this right in the Kuwait desk.
And this is the cutest query.
And you can see that they know which starter previously or which was the last is now the first.
And they screw this down.
Remember we have 30% to be null and start from the descending.
That means z is the very first one and y and so on.
And likewise, if we go ahead and uh see first underscore name or last underscore name and go ahead
and check it, check the first name.
And they have Zorah, Zuri and the Zedekiah.
And that is the starting point.
So descent is applicable to last name the square head and check the last name.
Last underscore name.
And let's check it out.
So this is the last name.
And the same is applicable to country or any one of them.
We see.
country and check it out.
Yummy.
Now one of the Imro dates.
Now let's go ahead and check out the Imro dates in real underscore dates.
And let's go ahead and check it out.
And they are straight from the 2015.
The last date to check it out.
You can see 4050 to 2049.
Hope that is cool.
So that is a way the order by clause actually works.
So you sort out these either in ascending or descending order.
And whatever you do here you can actually do that right in here.
Okay.
And that we actually work at fine.
So go ahead and practice with these.
Check it out.
And if you have any question on that is go ahead and use the question and answer section.
And I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.