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

Complex SQL not working in query editor


rathi
Go to solution Solved by rathi,

Recommended Posts

Hi,

I have a query as

Select
attribute1,
attribute2,
attribute3,
attribute4,
attribute5,
attribute6,
attribute7,
attribute8,
attribute9,
 attribute10
From farmer df
where df.CompanyId =$P{company_id}
and 1= 
(case 
when $P{current_history} = 'Active' and df.partitionflag = 1 then 1
when $P{current_history} = 'Inactive' and df.partitionflag = 0 then 1
else 0
end)
 
The case part in the 'where' clause isn't working.
 
Any help on understanding how to solve this would be greatly appreciated
 
Thanks
Rathi
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

"and 1=
(case
when $P{current_history} = 'Active' and df.partitionflag = 1 then 1
when $P{current_history} = 'Inactive' and df.partitionflag = 0 then 1
else 0
end)"
 I'm not sure that's the way to do what you're trying to. Try this instead:
"...
and case
        when $P{current_history} = 'Active' and df.partitionflag = 1 then 1=1
        when $P{current_history} = 'Inactive' and df.partitionflag = 0 then 1=1
        else 1=0
    end
    "

 
Link to comment
Share on other sites

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...