Hi there,
I've recently submitted a thread #183-1648000 to remove all the min dated records but it kept the max.
I need to do the same thing but I need it to add the values in each of the rows before it roll up to max date. The sql below works but it only summing the max value from the date. I would like for it to sum all the rows per id but keep the record with the max date.
Select id, sum(value1), sum(value2), sum(value3)From
YourTableNameHere T
Left Join ( Select ID, Max(Dates) As MaxDate
From YourTableNameHere Group BY ID ) As A
On T.ID = A.ID And T.Dates = A.MaxDate
group by id
I've recently submitted a thread #183-1648000 to remove all the min dated records but it kept the max.
I need to do the same thing but I need it to add the values in each of the rows before it roll up to max date. The sql below works but it only summing the max value from the date. I would like for it to sum all the rows per id but keep the record with the max date.
Select id, sum(value1), sum(value2), sum(value3)From
YourTableNameHere T
Left Join ( Select ID, Max(Dates) As MaxDate
From YourTableNameHere Group BY ID ) As A
On T.ID = A.ID And T.Dates = A.MaxDate
group by id