Aggregate function for DateTime variables??

I have a table that contains a DateTime column, and another column that I want to use as the group indicator.  I haven't found a function that will select the latest or earliest of the DateTime values for each group.  Does one exist?

Thanks
LVL 1
garyz31Asked:
Who is Participating?
 
Mogalappa AdakiConnect With a Mentor Commented:
suppose your datetime column is x and other columns are y,z

assing x as getdate() value in your program to get the date of the entry of record in the table.

select y,z,x from tablename order by x desc
0
 
spcmnspffCommented:
I'm not sure, but will this do what you described?

Latest Date for each group:

Select Group, Max(Date)
From Table
Group By Group


Earliest Date for each group:

Select Group, Min(Date)
From Table
Group By Group
0
 
SYASSINCommented:
you can also combine the two above...

select Group, max(date), min(date)
from Table
group by group
0
 
garyz31Author Commented:
Thanks:  I got distracted from this project for quite a while.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.