New page for every group in iReport - jasper-reports

I'm using iReport 5.6.0 and i want to create new page for each group.
For example i have table people_i_know:
Id| Name | State
1 | Tom | friends
2 | Jim | friends
3 | Mike | enemy
4 | Alex | friends
5 | Julie| enemy
My SQL should be like this:
SELECT Id,Name,State FROM people_i_know GROUP BY State;
And in this example iReport should give me two pages with detail band like this:
This should be on page 1.
1 | Tom | friends
2 | Jim | friends
4 | Alex | friends
And this should be on page 2.
3 | Mike | enemy
5 | Julie| enemy
How do i make that iReport make something like this?

You do not need to group in query, just order them
SELECT Id,Name,State FROM people_i_know State ORDER BY State;
in jrxml
you will have a field relative to the State column
<field name="State" class="java.lang.String">
<fieldDescription><![CDATA[]]></fieldDescription>
</field>
create a group on State with attribute isStartNewPage="true"
<group name="State" isStartNewPage="true">
<groupExpression><![CDATA[$F{State}]]></groupExpression>
</group>
and now just put the fields you like to display in the detail band

Related

PostgreSQL - Setting null values to missing rows in a join statement

SQL newbie here. I'm trying to write a query that generates a scoring table, setting null to a student's grades in a module for which they haven't yet taken their exams (on PostgreSQL).
So I start with tables that look something like this:
student_evaluation:
|student_id| module_id | course_id |grade |
|----------|-----------|-----------|-------|
| 1 | 1 | 1 |3 |
| 1 | 1 | 1 |7 |
| 1 | 2 | 1 |8 |
| 2 | 4 | 2 |9 |
course_module:
| module_id | course_id |
| ---------- | --------- |
| 1 | 1 |
| 2 | 1 |
| 3 | 1 |
| 4 | 2 |
In our use case, a course is made up of several modules. Each module has a single exam, but a student who failed his exam may have a couple of retries. The same module may also be present in different courses, but an exam attempt only counts for one instance of the module (ie. student A passed module 1's exam on course 1. If course 2 also has module 1, student A has to retake the same exam for course 2 if he also has access to that course).
So the output should look like this:
student_id
module_id
course_id
grade
1
1
1
3
1
1
1
7
1
2
1
8
1
3
1
null
2
4
2
9
I feel like this should have been a simple task, but I think I have a very flawed understanding of how outer and cross joins work. I have tried stuff like:
SELECT se.student_id, se.module_id, se.course_id, se.grade FROM student_evaluation se
RIGHT OUTER JOIN course_module ON course_module.course_id = se.course_id
AND course_module.module_id = se.module_id
or
SELECT se.student_id, se.module_id, se.course_id, se.grade FROM student_evaluation se
CROSS JOIN course_module WHERE course_module.course_id = se.course_id
Neither worked. These all feel wrong, but I'm lost as to what would be the proper way to go about this.
Thank you in advance.
I think you need both join types: first use a cross join to build a list of all combinations of students and courses, then use an outer join to add the grades.
SELECT sc.student_id,
sc.module_id,
sc.course_id,
se.grade
FROM student_evaluation se
RIGHT JOIN (SELECT s.student_id,
c.module_id,
c.course_id
FROM (SELECT DISTINCT student_id
FROM student_evaluation) AS s
CROSS JOIN course_module AS c) AS sc
USING (course_id));

Display 20 records per page in SSRS report

I'm trying to make an ssrs report show 20 rows per page and I've tried using
=Ceiling(RowNumber(Nothing)/20)
THIS DOES NOT WORK.
My rows contain a field that counts a number so it's just making that one field equal 20 for each page. Is there any way to make the tablix object only print a set number of rows per page so it's not reliant on the group by of the dataset?
I've also tried changing that 'nothing' to a field in the dataset but that throws an error.
Here's how my report tablix is set up:
| Part | Part Description | Part Qty | Part Weight | Total Weight |
|[Part]|[Part Description]|[SUM(PartQty)]|[Part Weight]|[SUM(TotalWeight)]
What I expect to get with the =Ceiling expression:
| Part | Part Description | Part Qty | Part Weight | Total Weight |
|PART1 |Part 1 Desc |12 |5.00 |[60.00]
|PART2 |Part 2 Desc |3 |5.00 |[15.00]
|PART3 |Part 3 Desc |5 |5.00 |[25.00]
|PART4 |Part 4 Desc |7 |5.00 |[35.00]
...Continue until 20 rows then page break
This is what I'm getting:
| Part | Part Description | Part Qty | Part Weight | Total Weight |
|PART1 |Part 1 Desc |12 |5.00 |[60.00]
|PART2 |Part 2 Desc |3 |5.00 |[15.00]
|PART3 |Part 3 Desc |5 |5.00 |[25.00]
--Page Break
|PART4 |Part 4 Desc |7 |5.00 |[35.00]
The field PartQty will count up to equal 20 then a page break.
You need to do the following:
Add a new row group and the the "group on" option to =CEILING(RowNumber(nothing)/20). This group should be the outermost group so if you only had a details group you could right click the details group and choose "add group => parent group"
Delete the new column if one was just created - we don't need this.
Right-click the new row group you created in hte row gorup panel at the bottom of the screen and click 'Properties'
In the "Page Breaks" section, set the option to 'Between each instance of a group'
Note: Whilst this will do what you want be aware that it won't actually set the number of rows per page, it sets the number of rows per group and then puts a break between each group. If you set the value in CEILING to 100 for instance, each group probably go over several pages.

Talend txmlmap generate Sequence for Child

I am new to talend and trying to parse xml document and generate etl sequence to maintain the child parent relationship. Situation here is I have a xml like this :
<RDF>
<footPrint>
<custid>123</custid>
<item>
<itemCd>apple</itemCd>
</item>
<item>
<itemCd>orange</itemCd>
</item>
</footPrint>
<footPrint>
<custid>456</custid>
<item>
<itemCd>grapes</itemCd>
</item>
<item>
<itemCd>kiwi</itemCd>
</item>
</footPrint>
</RDF>
And the output I am trying to achieve is :
id | Custid | item_seq | item
-------------------------------
1 | 123 | 1 | apple
1 | 123 | 2 | orange
2 | 456 | 1 | grapes
2 | 456 | 2 | kiwi
Any help will be appreciated.
use tFIleInputXML and set Xpath loop query to "/RDF/footPrint/item"
add two columns to schema i.e. cust_id and item. these column will automatically reflet in mapping content.
than for cust_id set Xpath query to - "../custid"
for item set Xpath query to "itemCd"
you will get your result.
hope this help...

Crystal 2008: Suppress record with multiple criteria

Crystal report looks like this:
No.| Name | Test - | Date
1 --| Fido - | yes -- | 1/2/2010
2 --| Rover | no --- | 1/2/2010
3 --| Fido - | yes -- | 1/2/2010
4 --| Fido - | yes -- | 1/8/2010
5 --| Rover | no --- | 1/8/2010
There are lots of observations with much duplication. Currently report suppresses records if duplicate in first column. Only records 1 and 2 would show up.
I need to be able to suppress records where both columns 1 and 3 are the same regardless of what is in column 2. In this case records 1,2,4,5 would all show up.
You can do this. try below way.
Create an array with the values first, For that purpose concatenate the required fields and create an array and select only those that are unique.
create a formula #finalvalues
Global Stringvar array mylist;
if Name&ToText(Date) in mylist
Then
1
else
mylist:=mylist+Name&ToText(Date);
0;
Now go to the supress part of the section where fields are placed and write below code.
if {#finalvalues}=1
then true
else false

How to decompose the relation into 5NF?

The example provided in the Fifth Normal Form has ACP(Agent, Company, Product) relation with the following data:
-----------------------------
| AGENT | COMPANY | PRODUCT |
|-------+---------+---------|
| Smith | Ford | car |
| Smith | Ford | truck |
| Smith | GM | car |
| Smith | GM | bus |
| Jones | Ford | car |
-----------------------------
Rule applied is if an agent sells a certain product, and he represents a company making that product, then he sells that product for that company.
The relation is decomposed into 3 relations according to constratint 3D: AC(agent, company), AP(agent, product) and CP(company, product). Hence the join dependency is *{(agent, company), (agent, product),(company, product)}. According to the definition of 5NF, a table R is in fifth normal form (5NF) or project-join normal form (PJ/NF) if and only if every join dependency in R is implied by the keys of R. But none of the projections contain a key, since the key is {agent, company, product} itself.
Another example provided in the book by C.J. Date contains a similar relation shipments(suppier_number, part_number, project_number) and the relation is decomposed similarly stating constratint 3D. However, the definition of 5NF doesn't state about the constratint 3D.
So, I have a few questions on the scenario presented above:
What is constratint 3D?
What if the relation has one more attribute "region" making ACPR(agent, company, product, region)?