Reply to Re: SQL Statement to return first unique record

Your name:

Reply:


Posted by othellomy on 01/19/07 06:07

Hi Jim,
Following might work:
select c1, c2, (select top 1 c3 from t1 a where a.c1 = t1.c1 and a.c2 =

t1.c2 order by a.c3 asc)
from t1
group by c1, c2

jim wrote:
> I've been searching and trying out SQL statements for hours and I'm
> still having a problem.
>
> I'm querying 3 tables... and I only want the first unique record
> returned.
>
> Currently, the data returned looks like this..............
>
> New York New York A
> New York New York B
> New York New York C
> Los Angeles California A
> Los Angeles California B
> Los Angeles California C
>
>
> I want the select statement to return this instead...
>
> New York New York A
> Los Angeles California A
>
> I'm using MS SQL server.
>
> please help?
>
>
> thanks for your help.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация