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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding Duplicates in a Column

Status
Not open for further replies.

DBADoug

Programmer
Oct 25, 2000
27
US
How can I write a query that hides duplicates in a column, but displays the rest of the row like:

Title Name
----- --------
MR Jones
Smith
Brown
MS Jones
Smith
Brown

In Oracle the keyword would be nodup.
I would appreciate any help.

 
Can you give an example of the original data and the result you would want from that? I'm not entirely sure what you're after at the moment.

--James
 
The easy answer.. You don't.

This sort of magic is done using an intellegent client like a VB flexigrid.

THe hard answer.. YOu could probably use recursive querys and temp tables to Massage the results, but you will probably be better put doing this at the client.

my .0000001 c

Rob
 
The original data contains the title, like I listed below, but I'm looking for a way to just output the first occurance of the title.

Title Name
----- --------
MR Jones
MR Smith
MR Brown
MS Jones
MS Smith
MS Brown
 
Hi,

Try this query... do u have an identity field in this table.. if u have u can use that instead of join on the name and title, it will be more efficient...

SELECT
CASE (SELECT Count(Name) FROM TBL T1 WHERE T1.Title=T.Title AND T1.name <= T.Name)
When 1 Then Title
Else ''
END Title,Name FROM TBL T
GROUP BY TITLE,NAME

Hope it helps

Sunil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top