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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / krishnamoorthy.n

select distinct * from <tablename>

Is This Answer Correct ?    4 Yes 3 No

Post New Answer

More SQL Server Interview Questions

About Indexed Views? with example? plz reply...

2 Answers  


Insert syudents details in table.Current system date &time insert into joining time.How do insert?( in sysdate only return current system date how do add time?)

0 Answers  


What type of Index will get created after executing the above statement?

0 Answers  


which query u can write to sql server doesn't work inbetween 7.00PM to nextday 9.00AM

5 Answers   Wipro,


what is the difference between Delete and Truncate

4 Answers   CarrizalSoft Technologies, Geo Research Centre,


What is change data capture (cdc) in sql server 2008?

0 Answers  


What is the difference Between Sql-server 2000 & 2005

3 Answers   Value Labs, Wipro,


what is bit datatype? : Sql server database administration

0 Answers  


Suppose you want to implement the one-to-one relationships while designing tables. How would you do it?

0 Answers  


Why I have to use stored procedures?

0 Answers   Cognizant,


Explain subquery and state its properties?

0 Answers  


Which is best Subquery (or) joins in sql server? explain why

2 Answers  


Categories