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 |
kond.mohan
Posting Yak Master
213 Posts |
Posted - 2013-07-11 : 07:16:15
|
hi i have created query using SSMS 2012. used by ctes and Temp tables.i got the output below manner.empno,achivasondate,%ofachivedyear,avgbudget,cumlative 12 ,4.25 ,4.25 ,6 ,6 12 ,1.31 ,5.56 ,6 ,12 12 ,0.23 ,5.79 ,6 ,18i want see my report only final row of the cumulative data.below described way 12 ,0.23 ,5.79 ,6 ,18is there any way to pick the the data in above manner. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-11 : 07:20:07
|
do you've date or a sequence number (id/rowno) field?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
kond.mohan
Posting Yak Master
213 Posts |
Posted - 2013-07-11 : 08:12:11
|
hi vishak ,i have a monthyear(date field)field.and don't have a sequence number. |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-07-11 : 08:15:01
|
[code]SELECT empno,achivasondate,[%ofachivedyear],avgbudget,cumlativeFROM( SELECT *, ROW_NUMBER() OVER (PARTITION BY empno ORDER BY YourDateField DESC) AS RN FROM ( YourOriginalQueryHere ) s1) s2 WHERE RN = 1;[/code] |
|
|
|
|
|
|
|