Quantcast
Channel: SQL Server Reporting Services, Power View forum
Viewing all articles
Browse latest Browse all 10045

Putting a CASE statement before a SUM statement

$
0
0

I am trying to output a series of values by Month but before I do that I want to decide whether I take the quote value or the requoteddifference value from each record, once I then have those values I want to sum by Month which I am ok with.

This is my current Select statement but it gives me two separate sums for Quote amount and Requoteddifference amount when what I want is one Sum with one or the other value in.

SELECT        SUM(FilteredQuote.totalamount) AS Value, YEAR(FilteredQuote.abp_datequotesent) AS QuoteYr, MONTH(FilteredQuote.abp_datequotesent) AS QuoteMonth, SUM(FilteredQuote.abp_requotedifference) AS requote

So what I really want to do is a CASE statement instead of the first SUM to say

CASE WHEN FilteredQuote.abp_requotedifference <>0.00 THEN FilteredQuote.abp_requotedifference ELSE FilteredQuote.totalamount END AS Value I then want to sum this result

- but this does not work - please advise


Viewing all articles
Browse latest Browse all 10045

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>