Jump to content
We've recently updated our Privacy Statement, available here ×

optional HAVING clause in Query


arianhojat

Recommended Posts

i have 4 variables that if they are set like so in Query via parameters:

 

HAVING

(Clients.Fname=$P{FirstName})

AND

(Clients.Lname=$P{LastName})

AND

(WIP.Wipdate Between $P{StartDate} And $P{EndDate})

 

 

but would like it to be smart and only build certain parts of query if parameter is set to something other than null.

 

so if $P{FirstName} and $P{LastName} are set then the HAVING Clause will only have...

 

HAVING

(Clients.Fname=$P{FirstName})

AND

(Clients.Lname=$P{LastName})

 

if just

$P{StartDate} and $P{EndDate}

then

HAVING

(WIP.Wipdate Between $P{StartDate} And $P{EndDate})

 

if none, then no HAVING clause at all.

 

Any good ways to approach this?

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Popular Days

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...