Actually, there is no difference between DISTINCT and UNIQUE.
SELECT UNIQUE is an old syntax which was used in oracle description but later ANSI standard defines DISTINCT as the official keyword.
After that oracle also added The distinct statement is used to fetch unique records from table The distinct sql statement removes duplicate records from fetched data.The distinct statement is used with Select statement.
Note: SQL SELECT UNIQUE and SQL SELECT DISTINCT statements are same.
The DISTINCT keyword can be used to return only distinct (different) values.
SELECT DISTINCT column_name,column_name FROM table_name;
Let's try to understand it by the table given below:
|Student Name||Gender||Mobile||Home Town|
The following SQL statement selects only the distinct values from the "City" columns from the "Customers" table:
SELECT DISTINCT gender FROM student ;
The SQL COUNT() function is used to return the number of rows in a query. The count() function is generally used in SQL SELECT function. It is very useful to count the numbers of records.
Let's see the syntax of SQL COUNT statement.
SELECT COUNT (expression) FROM tables WHERE conditions;
Let's see the examples of sql select count function.
SELECT COUNT(name) FROM employee_table;
It will return the total number of names of employee_table. But null fields will not be counted.
SELECT COUNT(*) FROM employee_table;
The "select count(*) from table" is used to return the number of records in table.