Using case when/if else in jasper dataset sql

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!

mayuri.kadam's picture
Joined: May 30 2017 - 10:52am
Last seen: 5 years 8 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

mayuri.kadam - 5 years 8 months ago

1 Answer:

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.

hozawa's picture
171153
Joined: Apr 24 2010 - 4:31pm
Last seen: 3 years 9 months ago
Feedback
randomness