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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Query returning too many rows

Author  Topic 

missrao
Starting Member

4 Posts

Posted - 2006-02-12 : 19:30:39
Hi all,

I'm joining two tables, one for a name, one for a date. I want the first date associated with each name. I only want one record per name. Each name/date combination is distinct, so that function won't help. I looked at the TOP function, but I don't know how many distinct names I'm going to be getting, so I don't think that function will help me.

Does anyone have any suggestions?

Thanks a lot!

Miss Rao

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2006-02-12 : 19:38:13
how about:

select name
,min(Date)
from myTable
group by name


Be One with the Optimizer
TG
Go to Top of Page

missrao
Starting Member

4 Posts

Posted - 2006-02-12 : 21:43:05
Fabulous! That works with my test data. Thank you very much.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-13 : 01:31:36
Also learn SQL
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
http://www.sql.org/sql-database/sql-tutorial/


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -