View Single Post
  #1 (permalink)  
Old January 17th, 2007, 11:49 AM
deontae45 deontae45 is offline
Authorized User
 
Join Date: Sep 2006
Location: Montgomery, Alabama, USA.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default CASE WHEN WHERE CLAUSE

Hi everybody, I need some help. I'm trying to get a solution from the following code: The WHERE clause is where I'm having problems. I'm trying to combine two statements in the where clause if I run them seprate I get the answer I'm looking for but I want to combine the two to get one answer. I think I need a CASE WHEN in the WHERE Clause. Can anyone help me??

SELECT SUM(mPremium) as 'Total Gross Prem', SUM(mPremium)+
SUM((Case When mPremium < 0 Then mPremium Else 0 End)) as 'Total Net Prem',
SUM((Case When mPremium < 0 Then mPremium Else 0 End))as 'Total Return Prem',
(SUM(mPremium)+ SUM((Case When mPremium < 0 Then mPremium Else 0 End)))* .06 as 'Total Tax Due'
From tblPolicy
Where (dtSubmitDate >= '1/1/2005' and dtSubmitDate <= '12/31/2005'and dtPolicyIncepDate < '1/1/2005'and
vchTransactionType <> 'NEW POLICY' and vchTransactionType <> 'Renewal')
and vchSLBLicNo = 'A172757'
and
Case When (dtPolicyIncepDate >='1/1/2005' and
dtPolicyIncepDate <= '12/31/2005' and vchSLBLicNO = 'A172757') end

Alexander Nelson
Programmer
__________________
Alexander Nelson
Programmer
Reply With Quote