posted 6/16/2009 by Vijendra Shakya
The SQL DISTINCT keyword specifies that only distinct / non-duplicate results are to be returned and used together with the SQL SELECT keyword. We can apply DISTINCT on a single columns or to multiple columns. Create Table users ( FirstName varchar(50), City varchar(50) ) Insert into users (FirstName,City) values(null,'Noida') Insert into users (FirstName,City) values('vijendra','Delhi') Insert into users (FirstName,City) values('singh','Mumbai') Insert into users (FirstName,City) values(null,'CallCutta') Insert into users (FirstName,City) values('shakya','Hyderabad') Insert into users (FirstName,City) values('vijendra',null) Insert into users (FirstName,City) values('vijendra',null) The SQL DISTINCT clause is used together with the SQL SELECT keyword, to return a dataset with unique entries for certain database table column. Select Distinct FirstName from users this Query gives following results FirstName Null shakya singh vijendra
Distinct on the multiple column,In this Distinct returns the unique Values of both column values combination. SELECT DISTINCT FIRSTNAME,CITY FROM users
this query gives following results: FirstName City NULL CallCutta NULL Noida shakya Hyderabad singh Mumbai vijendra NULL vijendra Delhi
What kind of email newsletter would you prefer to receive from CodeAsp.Net?18