Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Select Distinct

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-02-18 : 23:46:36
Mike writes "My table has 6 fields close_info, field, name, table, sorder. My problem is that "field" might duplicate entries .. I only want one of the entries returned ... so I would do a SELECT DISTINCT field FROM ... but ... I still need the other fields b/c I am ordering by "table" and "sorder" fields .. and if I do SELECT DISTINCT * FROM .. then it still returns records with the same "field" value .. so how can I select "field" distinct and still get the other fields ? Thanks.

Cheers,
Mike"

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2003-02-19 : 08:06:17
As there are multiple entries for the other columns you need to determine which of those should be included in the result.

C1 C2
-- --
1 A
1 C
2 B

if you only want distinct values of C1 which value from c2 should be choosen?

Go to Top of Page
   

- Advertisement -