I have an SSRS report where a parameter can take 3 values. The select query is the same in all cases but the where clause needs to check different date fields based on the parameter value. Is this possible in the same query?
Query:
SELECT OrdNO, OrdType, customer, SalesRep, FundDate, DisbursementDate, Branch, SalesPrice
FROM Orders
-- Case @ReportType=1, use FundDate
where (FundDate >= @FromDate and FundDate <= @ToDate)
-- Case @ReportType=2, use DisbursmentDate
Where (DisbursementDate >= @FromDate and DisbursementDate <= @ToDate)
-- Case @ReportType=3, use both dates
where (FundDate >= @FromDate and FundDate <= @ToDate) or (DisbursementDate >= @FromDate and DisbursementDate <= @ToDate)