Using IF THEN ELSE In SQL Views
Posted on 2009-07-06
I have three different database fields (from different tables) that depending upon the scenario need to be the field that is used to be picked up by reports as a selection criteria.
I need to intgegrate an IF THEN ELSE into a SQL view so that it shows this value regardless. How do i do this? The concept of the query is as follows:
IF order.custA = 'ABC' then order.custB
Else if stock.cust is null then sales.cust
In every case it is a string value. Ideally i want to be able to pass that result into Crystal as a parameter. I have tried doing this in Crystal and it kills the performance, so really need to pass this directly from SQL.
Any ideas would be appreciated.
Thanks in advance.