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
What is raid and what are different types of raid levels?
What are the basic functions for master, msdb, model, tempdb and resource databases?
What structure can you implement for the database to speed up table reads?
Explain nested trigger in sql?
Do you know what is a with(nolock)?
What is a fan-out query in SQL Azure?
How can we solve concurrency problems?
Suppose you want to implement the following relationships while designing tables. How would you do it?a.) One-to-oneb.) One-to-manyc.) Many-to-many
why does a sql statement work correctly outside of a user-defined function, but incorrectly inside it? : Sql server administration
whats the maximum size of view state??
What are the filtered indexes?
Is truncate a dml command?
What is awe?
What are the advantages of mirroring?
Explain stored procedure?