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 |
pacerier
Starting Member
5 Posts |
Posted - 2010-08-06 : 07:01:33
|
i have select*from clientusernameId Client UserName DateCreated1 1 new 1 2010-08-06 10:11:37.2002 1 new 11 2010-08-06 10:11:37.2003 1 new 111 2010-08-06 10:11:37.2004 2 new 2 2010-08-06 10:11:37.2005 3 new 3 2010-08-06 10:11:37.200 and if i do: select max(datecreated)from clientusername group by clienti get the rows i needed:2010-08-06 10:11:37.2002010-08-06 10:11:37.2002010-08-06 10:11:37.200 however the problem is that i will need the UserName column to show as well. right now the query is showing only the DateColumn of rows 3,4,5 but i need it to show the UserName column of rows 3,4,5--- |
|
Sachin.Nand
2937 Posts |
Posted - 2010-08-06 : 07:32:30
|
[code]select * from(select *,row_number()over(partition by Client order by id desc)as rid from yourtable)t where rid=1[/code]Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless. PBUH |
 |
|
pacerier
Starting Member
5 Posts |
Posted - 2010-08-06 : 11:29:04
|
hey thanks for the reply=)--- |
 |
|
|
|
|