?
Solved

Aggregate function for DateTime variables??

Posted on 2002-06-03
4
Medium Priority
?
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 5

Expert Comment

by:spcmnspff
ID: 7052060
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
ID: 7052640
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 300 total points
ID: 7055408
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
ID: 7117626
Thanks:  I got distracted from this project for quite a while.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

718 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