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
 General SQL Server Forums
 New to SQL Server Programming
 Earliest - Latest Dates

Author  Topic 

srucker
Starting Member

26 Posts

Posted - 2010-03-23 : 09:37:33
I am building a temp table to store a bunch of grouped records and need to get the earliest and latest dates for each group.

1 1 1/1/2008 - 12/31/2008
1 2 1/1/2010 - 12/31/2010
1 3 1/1/2009 - 12/31/2009

trying to result w/:
1/1/2008 - 12/31/2010


thx in adv!

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-03-23 : 09:42:54
[code]
select col1, min(start_date), max(end_date)
from sometable
group by col1
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

srucker
Starting Member

26 Posts

Posted - 2010-03-23 : 09:47:09
min, max
nice! Thank you!
Go to Top of Page
   

- Advertisement -