Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DISTINCT QUERY

Status
Not open for further replies.

MrBaRRon

Programmer
Aug 8, 2003
39
IT
Hi everybody,

I would like to select all "id" in a table ONLY where "raff" is distinct.

I think it should be such a thing:

SELECT id FROM mytable WHERE (SELECT DISTINCT raff) or

SELECT id FROM (SELECT DISTINCT raff FROM mytable)

So what is the correct syntax

Thnak U

BaRRon

 
What is the structure of the table?

select id = max(id) , raff
from tbl
group by raff
having count(*) = 1



======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Also, depending on the structure of ur table:
[tt]
Select Max(ID)
From MyTable
Group By Raff
[tt]

;-) Lenin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top