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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-04-26 : 07:59:57
|
| jrjimenez_cr@hotmail.com writes "i have a table and i need to recover the newest record per user and the counter of records each user have in the table, so if i have somebody that has 4 records and the last one was april 5th y need to recover the whole information i the record added in april 5th and the number 4, this for all the user that have records in the table." |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-04-26 : 08:58:04
|
| This can be achieved by using a derived table;select tbl.userid, ... , t.cntfrom tbl join(select userid, max(datecol), count(*) as cnt) as ton tbl.userid = t.userid and tbl.datecol = t.datecolrockmoose |
 |
|
|
|
|
|