Hello and welcome.
Thank you for signing up to this course.
It really means a lot to me in this field you all.
I will explain what is school distinct.
Key word is and also show an example of how to use it.
The escudo distained is used in combination with the rescue a select statement.
The main purpose of a distinct key word is to retrieve values that are different or unique from a table
set.
For example you have a table with salaries and there are duplicate entries for certain salary range
and you only want to return the unique salaries you would use as a distinct keyword to achieve that
purpose.
I have got a tool for our record editor and I am going to use be distained keyword to find out the salaries
that are unique or different in the Employees Table.
So we begin with the select key word.
We start with select
followed by the key word distinct
then next in need to specify the column names or column you trying to get the information from.
In this case the column I'm interested in is the salary column so I write down salary.
Next you specify the table where the column stays
and the name of the table where this salary column exist is Employees table
and then you end your statement with a semi colon.
So what this query is saying is that Select Distinct salary from employees.
What you will do it will only return this salary that that different in this table.
Before I run this script this query on fire run distinct.
I just want us to have a look at what the table looks like before we run the distinct so that you can
see the difference.
Right so I've written a query here.
It says select salary from employees so this will return all salaries from the Employees Table including
indeed duplicates.
If I go execute see this here is return or the salary.
You can see some duplicates salaries here 17000 17000 so Phi Phi scroll down you may see some more values
that are the same.
So yes.
So what this what the distinct will do it will remove all the duplicates.
So if you look at these value here they row.
There's a hundred and seven in total.
So what's wrong.
Distinct it will only return values that are unique.
So did duplicate entries will not be returned by the query.
Now that we've had a look at the salaries from the employee's table we are going to run the distinct
distinct will only return salaries that are unique.
So I go execute see it's returned a few rows now returned fifty eight rows in total previously returned
107 and we returned all the salary from the Employees Table.
Now it's returned only distinct values the values that are unique.
So all these values here.
They are all unique.
There's no duplicate goolagong one 9000 on one 8200 and so on.
In this video I explain what he has a distinct key word.
It's an.
We went through an example of using B has secured distilled key word in combination with the Escuela
select statement so distinct key word when used with is selected men will only return the values that
are different or unique from a database table.
Thank you so much.
Well watching you have a good day and take care.
Bye for now.