1
00:00:00,840 --> 00:00:02,330
Hello and welcome.

2
00:00:02,370 --> 00:00:05,700
Thank you for signing up to this course.

3
00:00:05,840 --> 00:00:09,470
It really means a lot to me in this field you all.

4
00:00:09,480 --> 00:00:12,810
I will explain what is school distinct.

5
00:00:12,810 --> 00:00:18,910
Key word is and also show an example of how to use it.

6
00:00:18,990 --> 00:00:26,580
The escudo distained is used in combination with the rescue a select statement.

7
00:00:26,850 --> 00:00:34,710
The main purpose of a distinct key word is to retrieve values that are different or unique from a table

8
00:00:34,980 --> 00:00:35,520
set.

9
00:00:35,600 --> 00:00:44,460
For example you have a table with salaries and there are duplicate entries for certain salary range

10
00:00:45,030 --> 00:00:53,910
and you only want to return the unique salaries you would use as a distinct keyword to achieve that

11
00:00:53,910 --> 00:00:55,590
purpose.

12
00:00:56,550 --> 00:01:07,940
I have got a tool for our record editor and I am going to use be distained keyword to find out the salaries

13
00:01:08,280 --> 00:01:13,520
that are unique or different in the Employees Table.

14
00:01:13,650 --> 00:01:17,390
So we begin with the select key word.

15
00:01:17,400 --> 00:01:18,960
We start with select

16
00:01:25,320 --> 00:01:28,440
followed by the key word distinct

17
00:01:33,150 --> 00:01:41,330
then next in need to specify the column names or column you trying to get the information from.

18
00:01:41,340 --> 00:01:50,070
In this case the column I'm interested in is the salary column so I write down salary.

19
00:01:50,070 --> 00:01:54,360
Next you specify the table where the column stays

20
00:01:58,560 --> 00:02:04,090
and the name of the table where this salary column exist is Employees table

21
00:02:08,670 --> 00:02:12,890
and then you end your statement with a semi colon.

22
00:02:13,800 --> 00:02:22,640
So what this query is saying is that Select Distinct salary from employees.

23
00:02:23,610 --> 00:02:32,070
What you will do it will only return this salary that that different in this table.

24
00:02:32,640 --> 00:02:39,020
Before I run this script this query on fire run distinct.

25
00:02:39,030 --> 00:02:46,410
I just want us to have a look at what the table looks like before we run the distinct so that you can

26
00:02:46,410 --> 00:02:47,730
see the difference.

27
00:02:47,820 --> 00:02:49,780
Right so I've written a query here.

28
00:02:49,900 --> 00:02:58,550
It says select salary from employees so this will return all salaries from the Employees Table including

29
00:02:58,550 --> 00:02:59,700
indeed duplicates.

30
00:02:59,700 --> 00:03:05,970
If I go execute see this here is return or the salary.

31
00:03:05,970 --> 00:03:16,860
You can see some duplicates salaries here 17000 17000 so Phi Phi scroll down you may see some more values

32
00:03:16,860 --> 00:03:18,380
that are the same.

33
00:03:18,860 --> 00:03:19,720
So yes.

34
00:03:19,890 --> 00:03:25,230
So what this what the distinct will do it will remove all the duplicates.

35
00:03:25,320 --> 00:03:27,770
So if you look at these value here they row.

36
00:03:27,840 --> 00:03:31,170
There's a hundred and seven in total.

37
00:03:31,170 --> 00:03:32,190
So what's wrong.

38
00:03:32,250 --> 00:03:36,460
Distinct it will only return values that are unique.

39
00:03:36,540 --> 00:03:42,330
So did duplicate entries will not be returned by the query.

40
00:03:42,360 --> 00:03:49,770
Now that we've had a look at the salaries from the employee's table we are going to run the distinct

41
00:03:50,330 --> 00:03:54,830
distinct will only return salaries that are unique.

42
00:03:55,050 --> 00:04:05,370
So I go execute see it's returned a few rows now returned fifty eight rows in total previously returned

43
00:04:05,560 --> 00:04:10,100
107 and we returned all the salary from the Employees Table.

44
00:04:10,230 --> 00:04:16,290
Now it's returned only distinct values the values that are unique.

45
00:04:16,680 --> 00:04:18,280
So all these values here.

46
00:04:18,300 --> 00:04:19,590
They are all unique.

47
00:04:19,590 --> 00:04:27,240
There's no duplicate goolagong one 9000 on one 8200 and so on.

48
00:04:27,810 --> 00:04:33,390
In this video I explain what he has a distinct key word.

49
00:04:33,390 --> 00:04:35,230
It's an.

50
00:04:35,460 --> 00:04:44,970
We went through an example of using B has secured distilled key word in combination with the Escuela

51
00:04:44,970 --> 00:04:53,820
select statement so distinct key word when used with is selected men will only return the values that

52
00:04:53,830 --> 00:04:58,100
are different or unique from a database table.

53
00:04:58,650 --> 00:04:59,800
Thank you so much.

54
00:04:59,870 --> 00:05:03,680
Well watching you have a good day and take care.

55
00:05:03,680 --> 00:05:04,810
Bye for now.
