Sunday, 16 June 2013

How To Select DiSTINCT value from Table

The SELECT DISTINCT statement is used to return only distinct (different) values.
The SQL SELECT DISTINCT Statement

In a table, a column may contain many duplicate values; and sometimes you only want to list the different (distinct) values.

The DISTINCT keyword can be used to return only distinct (different) values.
SQL SELECT DISTINCT Syntax
SELECT DISTINCT column_name1,column_name1
FROM TableName;

Create Table Customer
(

  City   varchar(125),
  CustomerName varchar(225)
)

Insert  into Customer(City, customerName) values('Patna', 'sureshsingh);
insert into Customer(City, CustomerName) values('patna' , 'Raj');

select 
Distinct City, CustomerName from customer

with the above syntax , we get distinct  record from the table.

0 comments:

Post a Comment