May 2, 2003 at 7:26 am
Hi, All Gurus.
How are U doing?
I have a Q for U.
First of all, take a look at these columns and rows.
-----------------------------------------
ID AcctName LogTime
1 123 04/30/03 8:10:00 AM
2 123 04/30/03 8:20:00 AM
3 123 04/30/03 8:20:35 AM
4 234 04/30/03 9:00:00 PM
5 234 04/30/03 9:01:00 PM
6 345 05/01/03 8:00:00 AM
7 345 05/01/03 8:00:00 AM
8 456 05/01/03 9:00:00 AM
My Q to U is how can I pull lasted modified row for each ACCT code?
ID column is IDENTITY column. Everytime user pulls and closes any data from table, it logs in this table.
Thx in advance.
Jay
May 2, 2003 at 8:48 am
If you need just the Id and the ACCTname you can do a simple group by.
select max(id) as ID,AcctName from Table1 group by AcctName
In case you need all the columns try the following:
SELECT t.ID, t.AcctName,t.Logtime
FROM Table1 t
JOIN (select max(id) as ID,AcctName from Table1 GROUP BY AccTName )t2
ON t.id =t2.id
Hope this helps
M
[font="Verdana"]Markus Bohse[/font]
May 2, 2003 at 8:54 am
Thx.Markus
That works..
Jay
May 2, 2003 at 11:00 am
Also, right after you insert into that table the last IDENTITY created is stored in @@IDENTITY variable. You could use that as a return value from your insert proc.
Darren
Darren
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply