对于一列的每一行数据,如何在经典报表中显示多行其他列?

For each row of data for a column, how to display multiple rows of other columns in a classic report?

我有一份经典报告,其中显示了来自 table 的 类 的例程。它看起来像这样:

我希望第一列“Class 日”有 5 个静态值,从“星期一”到“星期五”。在这些天中的每一天,都可以有多个 类,因此所有其他列对于“Class 天”列中的每一行都可以有多个行。我该怎么做?

这里有一个选项:使用 listagg 函数,其分隔符是 <br> 标记。对于所有使用它的列,将“转义特殊字符”属性 设置为“否”。

查询(以及一些示例数据):

with routine (datum, class_name, room) as
  (select to_date('15.06.2020 07:00', 'dd.mm.yyyy hh24:mi'), 'Maths'    , 502 from dual union all
   select to_date('15.06.2020 10:00', 'dd.mm.yyyy hh24:mi'), 'Physics'  , 555 from dual union all
   select to_date('15.06.2020 12:00', 'dd.mm.yyyy hh24:mi'), 'Bio'      , 301 from dual union all
   select to_date('16.06.2020 09:00', 'dd.mm.yyyy hh24:mi'), 'Chemistry', 422 from dual union all   
   select to_date('16.06.2020 13:00', 'dd.mm.yyyy hh24:mi'), 'English'  , 415 from dual
  )
select to_char(datum, 'dd.mm., day') dan,
  listagg(to_char(datum, 'hh24:mi'), '<br>') within group (order by datum) sat,
  listagg(class_name               , '<br>') within group (order by datum) classes,
  listagg(room                     , '<br>') within group (order by datum) rooms
from routine
group by to_char(datum, 'dd.mm., day')      
order by 1;

输出如下所示:


,根据@Jeffrey Kemp 的聪明想法,只需在第一列设置中断(打开报表的属性,向下滚动“中断格式”设置属性并将中断设置为“第一列”。

如果我是你,我会使用这个选项。

查询本身也更简单,不需要任何类型的聚合:

with routine as
  (sample data remains as it was in previous example)
select to_char(datum, 'dd.mm., day') dan,
  to_char(datum, 'hh24:mi') sat,
  class_name, 
  room
from routine
order by dan, sat;

通过你的查询,除了每天 class_day 列中的一条记录外,解决方案似乎可以留空。

Select case when rn = 1 then class_day end as class_day_final, 
       start_time, end_time, unit_title
  From
(Select t.*, 
       row_number() over (partition by class_day order by start_time) as rn
  From (<your_query>) t)
Order by class_day, rn

Classic Reports 支持中断格式,这应该可以满足您的需要。

转到属性,在中断格式下,将中断列设置为第一列