简体   繁体   中英

BIRT Report with SQL Oracle

The task is to make a simple report, that would look like this:

Trees Planted (Previous Week)      Quantity          Weight

OAK                                     720             544
APPLE                                   150             138
PEAR                                    430             411
PINE                                    602             589
CHESTNUT                                384             357

Sum:                                  2 286           2 039

I need to pull in the data of different planting events, which are expressed in columns: TREE, QTY, WEIGHT.

Now, the problem (or a challenge) is:

  1. In "Trees Planted" column, to show trees planted in last week, grouped and in alphabetic order.
  2. Sum quantity of each kind of a tree planted in last week and show the result in a proper row of 'Quantity' column. Than, the same with 'Weight'.

I guess, first point is as easy as:

select TREE
from TREETABLE

group by TREE
order by TREE

Than the second point would be something like:

select QTY
from TREETABLE

where SYSDATE >= next_day(trunc(sysdate), 'MONDAY') - 14
and SYSDATE < next_day(trunc(sysdate), 'MONDAY') - 7

and TREE='OAK'

But I know, that there's something wrong here.. Because this way we need to specify a TREE for each cell. It probably would be better to make it relative and linked with the first column. Or is there a feature in BIRT itself to make this kind of relation?

Well it looks like a simple "group by" query, no need for BIRT to enter into the scene at this point. Set this kind of query in the dataset and you are done:

select TREE, sum(QTY) as QTY, SUM(WEIGHT) as WEIGHT
from TREETABLE
where SYSDATE >= next_day(trunc(sysdate), 'MONDAY') - 14
and SYSDATE < next_day(trunc(sysdate), 'MONDAY') - 7
group by TREE
order by TREE

And create totals in the footer of the BIRT table

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM