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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Find last record of a collection

Author  Topic 

tegryan
Starting Member

22 Posts

Posted - 2002-07-17 : 19:11:23
Is there an aggregate function to find the last record in a collection? For example, I'm running a select statement that combines several records together using SUM, MAX, and Group By functions, but for one field I simply need to find the most recent value entered, which is also the last record in the collection. I can't find an aggregate function that seems to fit this, and I can't provide a where clause to accomplish this becuase this select statement is a substatement inside an inner join select statement.

Am I going about this the wrong way? Any help would be appreciated!

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-07-17 : 21:01:16
? how about Max(date_entered) ?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

tegryan
Starting Member

22 Posts

Posted - 2002-07-17 : 21:09:56
I tried that and it didn't work. The field that is causing me troubles returns multiple values, which causes an error to be returned. I'm trying to pick the most recent value out the column, and if I use MAX(Date_Entered) it still returns multiple values, or at least it tries to.

I ended up removing the join and using a sub-select statement using a where clause to find the most recent value. Thanks anyway tho.

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-18 : 09:20:35
I think your best bet is to post your ddl, the dml to insert some sample data and your expected rowset. I'm not sure I understand what you mean by "collection", as this is not a term I have come across before in relational databases.

<O>
Go to Top of Page
   

- Advertisement -