Jasper report doesn't show data as per the sorting order.


I have created a report using a student  table students have their priority to be treated in ascending order, Now my sql query works find on the database side but when I try to fire the same query from jasper report it doesn't give me the same result. I also tried to set up the sorting using the field value but it didn't work. I am using Jasper studio 5.5.1 final.

pathfinder2104.work's picture
Joined: Feb 27 2014 - 8:52pm
Last seen: 8 years 7 months ago

Kind of difficult to reply because you haven't specified which database you're using and your sql statement.

hozawa - 9 years 2 weeks ago

3 Answers:

Something was wrong on my end. I was placing the List element in the details band and hence the same set of data was being repeated all over many pages. I found it out when I created the jrxml for same report again ..... :) :)  Thank you for your efforts in reading and answering this question.  Especially fcerbell ... :) :)


pathfinder2104.work's picture
Joined: Feb 27 2014 - 8:52pm
Last seen: 8 years 7 months ago


The dataset sort feature is useful when the query language does not support the kind of sorting that you want to achieve.

If you get a list of cities from a SQL database and you want to sort them on their population fetched from a webservice, for example. It can also be because you want to sort and the query language does not allow sorting at all.

It your case, did you try to add an ORDER BY statement to your SQL query ? Did your qery returned what you expected when you ask to preview the data (the tab at the bottom of the query dialog) ?



fcerbell's picture
Joined: Aug 14 2011 - 1:00pm
Last seen: 8 years 2 months ago

I have used the dataset sorting feature using the same field, it didn't work. I am already using the ORDER BY in my query. I can see the desired output in my query browser. I have checked the data preview but no data is visible in there however for the same set of parameters I can see data in report and in query browser too.

pathfinder2104.work - 9 years 1 week ago

My solution for this problem.

In this case i have 2 parameters, both are from prompt and class java.util.date:

  1. start_date ( default value = DATE(2014,01,01)      ) 
  2. end_date ( default value = new java.util.Date()      )

And i have this "conditional"  in my query




WHERE  "here your date data column"   BETWEEN   CONVERT( DATE, $P{start_date} )     AND    convert(varchar(25),convert(date,$P{end_date }) ) + ' 23:59'

hmurillop's picture
Joined: Jun 7 2014 - 10:36am
Last seen: 8 years 7 months ago