Jump to content

Recommended Posts

Posted

Hi!  I have been able to write a simple query that offers three responses that works great.  However, I can't seem to figure out how to modify it so I can look to see if the first letter of the field begins with a "M".

Does anyone know how I can do this?  Here is the query I have created.

($F{DEVIATION_CATEGORY}.equals("Major Other")?"Other":$F{DEVIATION_CATEGORY}.equals("Major Treatment")?"Treatment":"MISSING")

I need the query to ask if $F{DEVIATION_CATEGORY} begins with "M", instead of equals "Major Other".

Any suggestions?

Thanx !

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted

Try

$F{deviation_category}.startsWith("M")?"M":"Missing"

or to take care of a nul value

($F{deviation_category}!=null)&&$F{deviation_category}.startsWith("M")?"M":"Missing"

For your information, these are Groovy/Java ternary operator expressions that JasperReports engine uses to process report fields. They are not query expressions thus cannot be used in a report SQL query stetament. Please refer to http://java.about.com/od/t/g/ternaryoperator.htm for more information.

Posted

Thanx tchen. I tried that already. However, I just realized I was not capitalizing the "W". Thanx so much! It's working for me now.

 

I am using this in a variable, not in the SQL query itself.

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