Using case when/if else in jasper dataset sql
Posted on July 21, 2017 at 4:18am
Hi All,
I am getting a very naive error, I have tried various SQL syntax. My backend DB is DB2.
In my SQL I am trying to do somthing like this:
select
case when (datatype=0) then "Unknown"
else when (datatype=1) then "Integer"
else when (datatype=2) then "Float"
else "varchar"
end Datatype_Df
from sampleDB;
Please help me with this syntax here...
Thanks!
Joined: May 30 2017 - 10:52am
Last seen: 5 years 8 months ago
Posted on July 23, 2017 at 3:13pm
If you're just getting syntax error in Jaspersoft Studio, just ignore it and save it. Most of the time, it's possible to execute even when Jaspersoft Studio shows syntax error if you are 100% sure that the sql statement is correct.
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 9 months ago
got the answer:
select
case
when (datatype=0) then "Unknown"
when (datatype=1) then "Integer"
when (datatype=2) then "Float"
else "varchar"
end Datatype_Df
from sampleDB