To expand on Dean's post, say you have the following 2 rows of data:

ColA, ColB, ColC
Dog, Mammal, Poodle
Dog, Mammal, Golden Retriever

Your query:
SELECT DISTINCT ColA, ColB
FROM table_1

Would Return:
Dog, Mammal

But if you want ColC, what result do you want:

Dog, Mammal, Poodle

OR

Dog, Mammal, Golden Retriever

So you see, there's no way to add another field since it doesn't make sense.



----- Original Message -----
From: "Cottell, Matthew" <[EMAIL PROTECTED]>
To: "SQL" <[EMAIL PROTECTED]>
Sent: Wednesday, December 12, 2001 3:52 PM
Subject: Selecting DISTINCT rows


> I'm trying to query the contents of a table based on the combination of 2
> columns being distinct.
> So far I have
>
> SELECT DISTINCT
> ColB, ColC
> FROM table_1
>
> This query pulls the rows I'm looking for,
> but now how do I get all the other columns that are in the table?
>
> I'm trying to get ColA, ColB, ColC, ColD, ColE.
>
> I tried
> SELECT *
> FROM table_1
> WHERE EXISTS (
> SELECT DISTINCT
> ColB, ColC
> FROM table_1)
>
> But this returns every row.
>
> Any suggestions?
>
> Matt
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to