Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:47:40+00:00 2026-06-17T18:47:40+00:00

Here’s the relation table StudentName Course Marks Peter Bio 65 Peter Chem 70 Peter

  • 0

Here’s the relation table

StudentName
Course
Marks



Peter
Bio
65

Peter
Chem
70



Peter
Music
80



David
Chem
50

How can I make something like the followings

Peter            Total : 215

Subject : Bio    -   65
Subject : Chem   -   70
Subject : Music  -   80

Peter            Total : 50

Subject : Chem   -   50
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:47:41+00:00Added an answer on June 17, 2026 at 6:47 pm

    I would not use a subreport for this as this can be achieved in a simpler way: You can utilize Report groups and variables to achieve this. Make sure that the data is sorted accordingly to the output.

    Preparation

    • Create a report group based on StudentName. Right Click in iReport in the report inspector on the report and select Add Report group. Follow the wizard, give it a name (e.g. Student), select field StudentName as group expression, add header but no footer.
    • Create a variable that holds the total for a student. Right Click in iReport in the report inspector on Variables and select Add Variable. In the properties panel configure as follows: Name: totalMarkByStudent, Variable Class: java.lang.Long, Calculation: Sum, Reset Type: Group, Reset Group: Student, Variable Expression: $F{Marks}. Leave the rest to its default values.

    Report Design

    • Drag and drop the Field StudentName from the report inspector into the report designer into the Student group header band. There will be a popup asking what kind of value shall be displayed, select The field value and click Ok.
    • Drag and drop the Variable totalMarksByStudent from the report inspector into the report designer into the Student group header band. Click on the text field and modify following settings in the properties panel:

      • Width: 200 (to allow more space)
      • Text field expression: "Total : " + $V{totalMarkByStudent}
      • Expression Class: java.lang.String
      • Evaluation Time: Group (meaning that the value gets evaluated once the processing of the group is finished)
      • Evaluation Group: Student
    • Drag and drop the fields Course and Marks from the report inspector into the detail band in the report designer. Right click on the course field and select Edit Expression. CHange the expression to "Subject : " + $F{Course} and click on Apply.

    With this configuration you achieve a report output as in the image below.
    report output

    For further reference here the complete JRXML using report group and variable:

    <?xml version="1.0" encoding="UTF-8"?>
    <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report3" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0dfbb9b2-a9ce-4447-beee-37d653140dd1">
        <property name="ireport.zoom" value="1.0"/>
        <property name="ireport.x" value="0"/>
        <property name="ireport.y" value="0"/>
        <queryString>
            <![CDATA[select * from (
    Select 'Peter' as StudentName, 'Bio' as Course, 65 as Marks
    union select 'Peter', 'Chem', 70
    union select 'Peter', 'Music', 80
    union select 'David', 'Chem', 50
    ) tbl
    
    order by StudentName, Course]]>
        </queryString>
        <field name="StudentName" class="java.lang.String"/>
        <field name="Course" class="java.lang.String"/>
        <field name="Marks" class="java.lang.Long"/>
        <variable name="totalMarkByStudent" class="java.lang.Long" resetType="Group" resetGroup="Student" calculation="Sum">
            <variableExpression><![CDATA[$F{Marks}]]></variableExpression>
        </variable>
        <group name="Student">
            <groupExpression><![CDATA[$F{StudentName}]]></groupExpression>
            <groupHeader>
                <band height="50">
                    <textField>
                        <reportElement uuid="ea996b6c-d41d-47bb-bef1-5df580b5c161" x="0" y="30" width="100" height="20"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[$F{StudentName}]]></textFieldExpression>
                    </textField>
                    <textField evaluationTime="Group" evaluationGroup="Student">
                        <reportElement uuid="8ddc9b5b-9c57-4fce-8ed0-587c6b54143c" x="180" y="30" width="200" height="20"/>
                        <textElement/>
                        <textFieldExpression><![CDATA["Total : " + $V{totalMarkByStudent}]]></textFieldExpression>
                    </textField>
                </band>
            </groupHeader>
        </group>
        <detail>
            <band height="20">
                <textField>
                    <reportElement uuid="f67b4e51-4da6-4758-b3d3-bd75de70c0f7" x="0" y="0" width="180" height="20"/>
                    <textElement/>
                    <textFieldExpression><![CDATA["Subject : " +  $F{Course}]]></textFieldExpression>
                </textField>
                <textField>
                    <reportElement uuid="ea82c278-d2f3-4467-bf5d-8dab9ff99ae3" x="180" y="0" width="277" height="20"/>
                    <textElement/>
                    <textFieldExpression><![CDATA[$F{Marks}]]></textFieldExpression>
                </textField>
            </band>
        </detail>
    </jasperReport>
    

    If you use a subreport instead

    I assume that the subreport is paraemterized with the student id shows the data for a given student. The main report shows the field StudentName and the subreport in the detail panel.

    • Create a variable total in the subreport that calculates the total for the student.
    • Create a variable totalByStudent in the main report with calculation type set to System.
    • Click on the subreport and in the properties panel click on Return values. Click Add and select: Subreport variable: total, Local Destination Variable: totalByStudent, rest leave to default. Click on Ok.
    • Drag and drop the variable totalByStudent into the detail band. Select it and in the Properties panel set Evaluation time to Band. The output will be the same as shown above.

    I recommend to use the approach with report group and variable as it reduces the complexity of the report, as well as performance for this way would be better.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here are the yammer api docs: http://developer.yammer.com/restapi/ Am I missing something here? How can
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
here is the html <table> <tr> <td class=break>mono</td> </tr> <tr> <td>c1</td> <td>c2</td> <td>c3</td> </tr>
Here are the tables I have: Table A which has entries with item and
Here's the situation, i want to have a user that can enter time on
here is what I am dealing with: I am given a table (Visit) with
Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.