UNIQUE statement is used to retrieve a unique or distinct element from the table.
Let's see the syntax of select unique statement.
SELECT UNIQUE column_name FROM table_name
SQL SELECT DISTINCT statement can also be used for the same cause.
The SQL DISTINCT command is used with SELECT keyword to retrieve only distinct or unique data.
SQL SELECT UNIQUE and SQL SELECT DISTINCT statements are same.
SELECT DISTINCT column_name ,column_name FROM table_name;
Let's try to understand it by the table given below:
Here is a table of students from where we want to retrieve distinct information For example: distinct home-town.
Now, it will return two rows.
The SQL COUNT() function is used to return the number of rows in a query.
The COUNT() function is used with SQL SELECT statement and it is very useful to count the number of rows in a table having enormous data.
SELECT COUNT(name) FROM employee_table;
SELECT COUNT(DISTINCT name) FROM employee_table;
The SQL SELECT TOP Statement is used to select top data from a table. The top clause specifies that how many rows are returned.
SELECT TOP 2 * FROM employee
It will return top records from the table.
The SQL first() function is used to return the first value of the selected column.SELECT FIRST(column_name) FROM table_name;
The SQL first() function is used to return the last value of the selected column.SELECT LAST(column_name) FROM table_name;
#SQL #Select #Keywords #Probyto #ProbytoAI
Subscribe and follow us for latest news in Data Science, Machine learning, technology and stay updated!