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 |
asifbhura
Posting Yak Master
165 Posts |
Posted - 2013-04-18 : 02:51:10
|
HelloI have two tables one which contains member information.while other contains renewal information which can be more than one records.I have autoID which creates automatically in second table and both tables are joined with memidnow I want to join 2 table but information from second table must get only last inserted recordswhat should be query ? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-18 : 02:57:29
|
[code]SELECT *FROM(SELECT ROW_NUMBER() OVER (PARTITION BY m.memid ORDER BY autoID DESC) AS Rn,*FROM Member mINNER JOIN Renewal rON r.memid = m.memid)tWHERE Rn=1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|