Data can be retrieved from table using SELECT [COLUMN] FROM [TABLE]. Sometime, the statement can retrieve multiple data that are the same. Figure 1 below shows the example of the duplication data in a SELECT statements.
Figure 1: Retrieve year of intake from table students. |
Noted in Figure 1, where the SQL statement returned 2 2018 figures in the result. This happen because there are two data with the same intake year in the table. SQL had a pre-defined function to remove duplicate data in a column. The SQL syntax is shown below:
The keyword DISTINCT will allow the SQL command to display a set of unique data only in a column. The example of using the particular command is shown in Figure 2 below: