1

I have a list of dates (more than 100) where i need to sum a particular column for each of these dates. I know the below doesn't work but it shows what i'm trying to do...please help

USE FIND
select SUM(a.rm_result_as_pct_of_nav)
from rpt.rm_Report_History a 
where
a.analysis_date IN( '20160330','20160228','20160131')
and a.criteria_Set = 'Daily' and a.ptf_id = '10039'
and a.stat_def_id=397

There are no errors but I just get 1 total. I need the total per date, so i can see at the end of each month the pct_of_nav is x.

2
  • Are you getting any errors? If so please post them Commented Aug 23, 2016 at 12:57
  • No errors but i just get 1 total...i need the total per date, so i can see at the end of each month the pct_of_nav is x Commented Aug 23, 2016 at 13:00

1 Answer 1

2

This will give you the sum and show the date;

SELECT
a.analysis_date
,SUM(a.rm_result_as_pct_of_nav) SumResult
FROM rpt.rm_Report_History a
WHERE a.analysis_date IN ('20160330','20160228','20160131')
    AND a.criteria_Set = 'Daily' 
    AND a.ptf_id = '10039'
    AND a.stat_def_id=397
GROUP BY a.analysis_date

If you don't want to restrict the dates then do something like this;

SELECT
a.analysis_date
,SUM(a.rm_result_as_pct_of_nav) SumResult
FROM rpt.rm_Report_History a
WHERE a.criteria_Set = 'Daily' 
    AND a.ptf_id = '10039'
    AND a.stat_def_id=397
GROUP BY a.analysis_date
Sign up to request clarification or add additional context in comments.

4 Comments

again only gives 30th June results, not the others
Ok, could you update your question and include your sample data? I'm assuming that one of the fields in the where clause is restricting the data. Try it without the where clause to check that it's working. Then add in the clauses and see which one restricts the data to only the 30th of June.
yes my bad, the dates i specified were not avaialbe,,,you answered it thanks
Happy to help. Feel free to upvote and mark as accepted if this answer has resolved the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.