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

In which year relase the 7.0& 2000 & 2005?

1 Answers  


What is buffer cash and log cache in sql server?

0 Answers  


How to make remote connection in database?

0 Answers  


Do you know what are different types of replication in sql server?

0 Answers  


What are the steps to insert a table?

0 Answers  






i want only duplicates rows from coloumn ex. emp_id(colomn name)1,1,2,3,3,4,5,5. so i want only duplicates no.

3 Answers   iFlex,


What is the correct order of the logical query processing phases?

0 Answers  


How many levels of sp nesting is possible?

0 Answers  


What is a system database and what is a user database?

0 Answers  


How to Generate a Series of Random Integers With T-SQL?

1 Answers  


How is sql used in sql server?

0 Answers  


What is a data source file?

0 Answers  


Categories