WEBVTT

00:07.700 --> 00:10.460
I welcome you back again to the virtual PostgreSQL.

00:10.460 --> 00:14.090
And here let's go ahead and learn about the keyword distinct.

00:14.420 --> 00:15.950
So what's the first thing like.

00:15.950 --> 00:16.730
What is distinct.

00:16.730 --> 00:22.820
And it's very important aspect in PostgreSQL or in SQL queries.

00:23.270 --> 00:30.950
Now you might have things like uh, let me say I want to select, uh, let me go ahead and select oh.

00:33.650 --> 00:40.040
I want to select, uh, all brown students or let me go ahead and select country.

00:42.350 --> 00:46.550
I want to start country from students.

00:47.450 --> 00:53.810
And if I go over here you can see I have a Russia, I have China, Russia, Thailand.

00:53.840 --> 01:02.090
And uh, if you go down here, you can see I have Indonesia and I have Indonesia, and I have Philippines,

01:02.120 --> 01:04.220
I have Philippines and Philippines.

01:04.250 --> 01:10.520
Now, remember, if you go down on this, you can continue to open up all this.

01:10.550 --> 01:11.000
What?

01:11.030 --> 01:13.610
I really love working over here.

01:14.450 --> 01:17.810
So if I go ahead and select country over here.

01:17.840 --> 01:21.230
Go ahead and select country and load this year.

01:21.260 --> 01:22.670
I have all this.

01:22.700 --> 01:27.740
And I can select most of these numbers for which most times I have China and I have China.

01:28.010 --> 01:32.300
And now I just want to select I want some of the countries that are here.

01:32.330 --> 01:34.490
I just want to know them by one.

01:34.520 --> 01:40.310
Like say China, then Poland, Indonesia, Philippines, Bulgaria, whatever.

01:41.060 --> 01:41.510
Again.

01:41.540 --> 01:47.570
Then Portuguese without repeating China, uh Philippines and uh, Czech Republic.

01:47.600 --> 01:50.120
So how can I be able to do that?

01:50.150 --> 02:03.050
So if I go ahead and say select a country from students and, uh, I see order, order by the country

02:04.280 --> 02:12.230
with a semicolon at the end and run this thing, you can see that this actually arranged this from Afghanistan

02:12.260 --> 02:16.070
down to Albania, Argentina.

02:16.070 --> 02:19.950
And if I scroll this down, let's go ahead and check it out.

02:19.950 --> 02:21.930
And I have Yemen.

02:21.960 --> 02:24.210
I have total of 1000 rules.

02:24.210 --> 02:28.200
And consider Yemen repeated many times and Vietnam repeated many times.

02:28.230 --> 02:33.930
Yes, because these are assigned to some of these rules or all of the rules.

02:33.930 --> 02:35.970
But I just want to know only.

02:36.000 --> 02:41.970
I just want to know the numbers of the countries and the distinct numbers and the countries that are

02:42.540 --> 02:44.370
inside this data set.

02:44.400 --> 02:53.310
So the way to do that is, uh, by using that keyword distinct, and I want to use the keyword distinct.

02:53.340 --> 02:55.980
All I need to do is I have to say select.

02:55.980 --> 03:00.450
And then I'll go ahead and insert distinct.

03:00.810 --> 03:09.780
So if I should put those distinct country, it means I want to select just one out of control repeated.

03:09.780 --> 03:15.780
Just one out of the countries are repeated to show the countries that are all in here.

03:15.780 --> 03:17.760
And if I run this query let's check it out.

03:17.790 --> 03:22.860
You can see you have Afghanistan, just one Albania, one American Samoa.

03:22.890 --> 03:24.900
Samoa or Angola?

03:24.930 --> 03:25.890
Argentina.

03:25.920 --> 03:29.130
Armenia, Australia and so on.

03:29.130 --> 03:39.390
And if I should go right down here, I have Yemen and Vietnam and have a row of modern 24 of 124 and

03:39.390 --> 03:48.390
something is applicable to, let me say first underscore name.

03:48.390 --> 03:52.140
And if you select that from first underscore name.

03:52.200 --> 03:55.890
And when I say first underscore name.

03:55.890 --> 04:04.800
And if I run this first and check it out, you see we have rules of 941 instead of 1000, because there

04:04.800 --> 04:07.020
are names that are actually repeated by the Serbs.

04:07.020 --> 04:09.810
And that is applicable to all of these.

04:09.810 --> 04:12.990
And you can also arrange these in alphabetical order.

04:14.370 --> 04:16.950
So this actually starting from alphabetical order.

04:16.950 --> 04:23.130
And if you want that to start from descending order, all I need to do is I'll go ahead and add this

04:23.130 --> 04:24.720
keyword descend.

04:24.750 --> 04:29.880
And if I run this it's going to start from the last zero.

04:29.970 --> 04:32.910
And that is applicable to countries as well.

04:33.090 --> 04:36.870
You can also do that for dates if you go ahead and check dates.

04:37.050 --> 04:41.560
So we want to see dates underscore all that is in rule.

04:41.590 --> 04:43.420
Deeds in rule.

04:43.450 --> 04:44.980
Underscore dates.

04:45.850 --> 04:48.670
And then I have to change this to in rule.

04:49.930 --> 04:51.700
Underscore dates.

04:51.730 --> 04:53.650
And let's go ahead and execute the query.

04:53.650 --> 05:04.600
And uh we have 2050 1010 2050 uh 1007 both are different.

05:05.050 --> 05:09.970
And we have a total rule of guitar and 64 of 864.

05:10.450 --> 05:20.530
So the distinct value helps you to distinguish between repeated numbers of our data in a row and in

05:20.530 --> 05:21.100
a table.

05:21.130 --> 05:26.230
You actually get only one out of repeated values.

05:26.800 --> 05:27.580
How that is cool.

05:27.580 --> 05:33.190
So go ahead and apply this check it out program with it, and if you have any question, go ahead and

05:33.190 --> 05:34.690
use the question and answer section.

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

05:37.210 --> 05:38.230
Thank you so much.

05:38.230 --> 05:41.110
And I'm going to see you in the next video lecture.
