0

So I have a scenario.

Must have these 4 application fees set up with no end date or end date in future.

(FeeTypeID = 16 AND FeeRequirementTypeID = 18)
(FeeTypeID = 17 AND FeeRequirementTypeID = 18)
(FeeTypeID = 18 AND FeeRequirementTypeID = 18)
(FeeTypeID = 19 AND FeeRequirementTypeID = 18)

Now how would I put this into a if statement?

Raidri
  • 17,258
  • 9
  • 62
  • 65
ace.nasir
  • 1
  • 1
  • 4

1 Answers1

0

Use AND and OR:

select ...
from ...
where  
(
  (FeeTypeID = 16 AND FeeRequirementTypeID = 18) or
  (FeeTypeID = 17 AND FeeRequirementTypeID = 18) or
  (FeeTypeID = 18 AND FeeRequirementTypeID = 18) or
  (FeeTypeID = 19 AND FeeRequirementTypeID = 18) or
)
and
(
  end_date is null or
  end_date > now() -- or whatever expression your dbms uses for today
);

EDIT: I just notice that ist always FeeRequirementTypeID = 18. So simply:

select ...
from ...
where FeeRequirementTypeID = 18 
and FeeTypeID in (16,17,18,19)
and ( end_date is null or end_date > now() );
Thorsten Kettner
  • 89,309
  • 7
  • 49
  • 73
  • Thanks for your reply. This is great for the SQL Side. If I wanted to put this in a If statement? How would I go about doing this? Or would it be better to put it in the select statement when populating the datatable? Because the data is coming via a stored procedure I do not think I could put this in the SP as the SP is bringing in other data which I am using elsewhere. – ace.nasir Apr 10 '14 at 15:14