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

What are the types of normalization?

0 Answers  


Advantages and disadvantages of stored procedures.

2 Answers   HCL,


What are the advantages of using a stored procedure?

0 Answers  


Explain insert into select statement?

0 Answers  


How will you collect the date from current date to last older 6 days date in sql server 2005

4 Answers  


What is the use of SCOPE_IDENTITY() function?

2 Answers  


What are “lost updates”?

0 Answers  


What is user-defined function?

0 Answers  


What are the steps you will take to improve performance of a poor performing query?

1 Answers  


I am using SQL Server 2005, I have some select and update statements in my query with WHERE clause I want to prevent these queries from SQL injection attacks. What are the steps and precautions to be taken for SQL Injection attacks? Does anybody have suggestions? Thanks in advance,

2 Answers  


What is Full Outer Join?

3 Answers  


Which autogrowth database setting is good?

0 Answers  


Categories