Monday, March 26, 2012

Query problem

Hi,

I've got a problem with the following query, i'd like to write this in SQL for reporting services.

if ($par == "Ok"){
$query .= ' and b.date is not null '
}

if ($par == "NOK"{
$query = 'and b.date is null'
}

How should I do this? If my parameter is OK, the date should be filled in. Otherwise...

THX

You can do something like this

select .... where @.par = 'Ok' AND b.date is not null

union

select .... where @.par = 'NOK' AND b.date is null

I haven't tested it but it should work. The idea being that only one side of the union can have a result because only one side's where clause will evaluate to true.

No comments:

Post a Comment