Solved

Aggregate function for DateTime variables??

Posted on 2002-06-03
4
225 Views
Last Modified: 2012-08-14
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
0
Comment
Question by:garyz31
4 Comments
 
LVL 5

Expert Comment

by:spcmnspff
Comment Utility
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
 
LVL 1

Expert Comment

by:SYASSIN
Comment Utility
you can also combine the two above...

select Group, max(date), min(date)
from Table
group by group
0
 

Accepted Solution

by:
Mogalappa Adaki earned 75 total points
Comment Utility
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
 
LVL 1

Author Comment

by:garyz31
Comment Utility
Thanks:  I got distracted from this project for quite a while.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now