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
 General SQL Server Forums
 New to SQL Server Programming
 issue on get latest date record

Author  Topic 

rajnidas
Yak Posting Veteran

97 Posts

Posted - 2014-04-10 : 06:21:45
hi every one, i am facing some problem with some query which has given below.
i want to get latest updated date on each transid and only for status =approved .
-------------------
out put would be
------------
id transid date status
3 101 3/1/2014 approved
6 103 1/2/2014 approved
table
-----------

id transid date status
1 101 1/1/2014 approved
2 101 2/1/2014 close
3 101 3/1/2014 approved
4 102 1/2/2014 approved
5 102 2/2/2014 close
6 103 1/2/2014 approved

i need help
Thanks

Rajnidas

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-04-10 : 06:34:38
Can you try this?

select id ,transid ,date ,status from
(
select row_number() over(partition by transid order by date desc) as sno, * from your_table
) as t
where sno=1 and status='Approved'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

rajnidas
Yak Posting Veteran

97 Posts

Posted - 2014-04-10 : 06:36:29

so much thanks
i got solution

rajnidas
Go to Top of Page
   

- Advertisement -