Within a SELECT do 2 Sum and show only 1
Hi Folks -
I was wondering if anybody knows how to get a single value result from 2 previous calculated results...
Here's my query...
__________________________________________________ ______________________
Select Year(dateeffective) as year1,Month(dateeffective) as month1,count(uwaction) as total1,
Sum(bound_premium) as Bound1,Sum(quoted_premium) as Quoted1,
IIF(Bound1>=Bound1,bound1,quoted1) as new_output
From q_quotes_tbl
Where dateeffective >= '01/01/05' and dateeffective <= '09/20/05' and lob_id=3 and quotetype='new' and
((Cast(bound_premium as numeric) is not null and Cast(bound_premium as numeric) > 0) or
(Cast(quoted_premium as numeric) is not null and Cast(quoted_premium as numeric) > 0))
group by year(dateeffective),Month(dateeffective)
order by year(dateeffective),Month(dateeffective)
__________________________________________________ ______________________
I am having a problem with this line:
IIF(Bound1>=Quoted1,bound1,quoted1) as new_output
What I want to do is to Sum two different fields, and then show me only the greater of the two fields totals.
Any and all help is appreciated.
Thanks.
Ford
|