View Single Post
  #2 (permalink)  
Old February 1st, 2012, 06:47 AM
disel2010 disel2010 is offline
Authorized User
Points: 448, Level: 7
Points: 448, Level: 7 Points: 448, Level: 7 Points: 448, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 86
Thanks: 1
Thanked 12 Times in 12 Posts
Default

Hi,

check out this previous thread to see why you cannot use a Case statement like that in the where clause:
Case Statement In Where Clause Logic

I would suggest to rewrite your sql as follows:
Code:
 
Select * from inventory i
where 
 i.TransactionType = '810'
 and 
 (
  ((@option = 1) and (i.PaymentDueDate between @begindate and enddate))
  or
  ((@option <> 1) and (i.CreateDate between @begindate and @enddate))
 )
Hope this helps
Reply With Quote
The Following User Says Thank You to disel2010 For This Useful Post:
Beginner_2012 (February 2nd, 2012)