Using case when/if else in jasper dataset sql

1

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: 4 years 6 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 - 4 years 6 months ago

1 Answer:

3

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
78152
Joined: Apr 24 2010 - 4:31pm
Last seen: 2 years 7 months ago
Feedback