October 16, 2009 at 11:38 am
I have this query:
select * from loandata where loan in(
0023835689,
0023837701,
0023833726,
0023838865)
I need to get the max date for each account. Acount number 0023835689 (for example) might have a different max date the 0023837701.
But I need to bring back all the columns (*) and I need the max date for each account
October 16, 2009 at 11:45 am
with cte as (
select *,row_number() over(partition by loan order by thedate desc) as rn
from loandata)
select * from cte where rn=1
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537October 16, 2009 at 11:50 am
Thanks Mark..
where do i put in the account numbers?
October 16, 2009 at 11:54 am
krypto69 (10/16/2009)
Thanks Mark..where do i put in the account numbers?
Here
with cte as (
select *,row_number() over(partition by loan order by thedate desc) as rn
from loandata
where loan in (....)
)
select * from cte where rn=1
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537October 16, 2009 at 12:18 pm
You rock
Thank you sooo much
Good karma to you and have a nice weekend.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply