Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how can u select the Distinct values in the table, table
having 20 columns , i want all columns

Answer Posted / uma

The SELECT DISTINCT Statement
The DISTINCT keyword is used to return only distinct
(different) values.
The SELECT statement returns information from table columns.
But what if we only want to select distinct elements?
With SQL, all we need to do is to add a DISTINCT keyword to
the SELECT statement:

Syntax
SELECT DISTINCT column_name(s)
FROM table_name

Using the DISTINCT keyword To select ALL values from the
column named "Company" we use a SELECT statement like this:
SELECT Company FROM Orders
"Orders" table

Company OrderNumber
Sega 3412
W3Schools 2312
Trio 4678
W3Schools 6798
Result

Company
Sega
W3Schools
Trio
W3Schools
Note that "W3Schools" is listed twice in the result-set.
To select only DIFFERENT values from the column named
"Company" we use a SELECT DISTINCT statement like this:
SELECT DISTINCT Company FROM Orders

Result:
Company
Sega
W3Schools
Trio
Now "W3Schools" is listed only once in the result-set.

Is This Answer Correct ?    6 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain where clause?

989


How to use union to merge outputs from two queries together in ms sql server?

1069


What are horizontal and vertical scaling?

172


How to generate create function script on an existing function?

1117


How do indexes help, types?

965


How to select all columns of all rows from a table with a select statement in ms sql server?

1114


If a stored procedure is taking a table data type, how it looks?

6449


Why and when do stored procedure recompile?

981


Please explain go command in sql server?

1057


How to resolve the orphan use problem? : sql server security

1014


what are cursors? : Sql server database administration

1061


explain different types of joins? : Sql server database administration

985


When would you prefer to have a minimum number of indexes?

911


What triggers long term care?

1038


What is SQL Azure Federations?

112