crystal reports - sql query with conditional where only works sometimes -


i'm creating report (in crystal reports xi) based on sql stored procedure in database. query accepts few parameters, , returns records within specified date range. if parameters passed in, used determine records return. if 1 or more parameters not passed in, field not used limit types of records returned. it's bit complicated, here's clause:

where  ((date > @start_date) , (date < @end_date))      , (@employeeid null or emp_id = @employeeid)      , (@clientid null or client_id = @clientid)     , (@projectid null or project_id  = @projectid)     , (@group null or group = @group) 

now, problem:

the query (and report) works beautifully old data, within range of years 2000-2005. however, clause not filtering data more recent years: returns records parameter @group null (ie: not passed in).

any hints, tips, or leads appreciated!

solved!

it had nothing clause, after all. had let sql server generate inner join me, should have been left join: many records recent years not contain entries in joined table (expenses), weren't showing up. interestingly, few recent records have entries in expenses table have null value group, why got records when @group null.

morals of story: 1. double check automatically generated; , 2. out null values! (n8wl - giving me hint closely @ nulls.)


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -