In a table, some of the columns may contain duplicate values. This is not a problem, however, sometimes you will want to list only the different (distinct) values in a table.
The DISTINCT statement can be used to return only distinct (different/that don'trepeat) values.
Syntax :
Let's create the table we will use
Script:
Check the table to see the data and the structure
Very good
Distinct() examples:
Example 1:
-let's see how many distinct ID's values we have:
Example 2:
-now let's see how many distinct DE (departments) we have in our test table;
-so we can see that thaw we have 6 rows in our table the distinct() function only shows the distinct values of DE column.
We can use conditions and other functions in the same statement with distinct() function.
For more on this function in future tutorials.