Select distinct value from data table in SQL


SELECT DISTINCT query is used to return different values from data table.

In database there are so many duplicate values and if you want to select only different data and row from table use distinct statement.


SELECT DISTINCT QUERY

SELECT DISTINCT Emp_name, Emp_City, FROM your_table_name;

Now will show you the difference between SELECT and SELECT DISTINCT 

SELECT Example
Following Sql Query select all duplicate rows from column Emp_name from table


SELECT Emp_name FROM Employee_table;

SELECT DISTINCT Example
Following Sql query select only distinct value from column Emp_name
From Employee_table


SELECT DITINCT Emp_name FROM Employee_table;

Example
Following SQL query selects and counts the different rows




SELECT COUNT (DISTINCT Emp_nameFROM Employee_table;

Comments

Post a Comment

Popular posts from this blog

Disable right click, Inspect Element and page source using JavaScript in Html and asp.net

Like Operator In Sql Server