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
 Other Forums
 MS Access
 SQL Distinct

Author  Topic 

PeteLeHoq
Starting Member

37 Posts

Posted - 2011-03-24 : 09:59:22
What SQL statement do you use to select distinct on one col and return two other ones. E.g

TeamNum | Col1 | Col2
1 | Oranges | Lemons
1 | Oranges | Apples
2 | Pears | Grapes
2 | Pears | Bananas
2 | Pears | Lemons

So the data returned would be:

Oranges | Lemons
Pears | Grapes

The distinct needs to be applied to the "TeamNum" col. I'm on a Access database.

Thanks.

edit: moved to proper forum

SMerrill
Posting Yak Master

206 Posts

Posted - 2011-04-29 : 19:26:46
[code]SELECT First(Fruit.Col1) AS Fruit1, First(Fruit.Col2) AS Fruit2
FROM Fruit
GROUP BY Fruit.TeamNum;
[/code]

~ Shaun Merrill
Seattle area
Go to Top of Page
   

- Advertisement -