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 2005 Forums
 Transact-SQL (2005)
 query help

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2009-12-30 : 07:58:34

I have a table appeals with userid,outcome,mydatetime

now I want to show a list ordered by mydatetime desc of all userid and the number of records for that user id - and the last mydatetime for that userid.)

can you help me?
(I need a list of all users adn how many records - but with the datetime of the last record)

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-12-30 : 08:09:30
select
userid,
count(*) as num_of_records,
max(mydatetime) as mydatetime
from appeals
group by userid
order by mydatetime desc


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2009-12-30 : 08:23:00
thanks :)
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-12-30 : 09:07:49
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -