SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 issue on get latest date record
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

rajnidas
Yak Posting Veteran

India
85 Posts

Posted - 04/10/2014 :  06:21:45  Show Profile  Reply with Quote
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

India
22761 Posts

Posted - 04/10/2014 :  06:34:38  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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

Edited by - madhivanan on 04/10/2014 06:35:14
Go to Top of Page

rajnidas
Yak Posting Veteran

India
85 Posts

Posted - 04/10/2014 :  06:36:29  Show Profile  Reply with Quote

so much thanks
i got solution

rajnidas
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000