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
 SQL Server Development (2000)
 need a little help about query

Author  Topic 

frkimrki
Starting Member

2 Posts

Posted - 2006-10-03 : 17:56:11
I have two tables, for example, first one is about users, other one is about actions of users, and now i need to get a list of all users and their last action, not all actions.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-10-03 : 18:33:18
[code]select *
from users u inner join actions a
on u.user_id = a.user_id
and a.action_time = (select max(action_time) from action x where x.user_id = u.user_id)
[/code]


KH

Go to Top of Page

frkimrki
Starting Member

2 Posts

Posted - 2006-10-04 : 04:18:11

thanx khtan, u help me a lot...i needed to do minor changes in the query, but it works now ;-)
Go to Top of Page
   

- Advertisement -