0

I have a classic report that displays a routine for classes from a table. It looks like this: enter image description here

I want the first column "Class Day" to have 5 static values from "monday" to "firday". In each of those days there can be multiple classes so all the other columns can have multiple rows for each row in the "Class Day" column. How can I do that?

4

3 回答 3

2

Classic Reports support break formatting which should do what you need.

Go to Attributes, under Break Formatting, set Break Columns to First Column.

于 2020-06-20T15:08:39.313 回答
1

Here's one option: use listagg function whose separator is the <br> tag. For all columns that use it, set "Escape special characters" property to "No".

Query (along with some sample data):

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;

Output looks like this:


Or, with a much less effort, according to @Jeffrey Kemp's smart idea, simply set break on the 1st column (open report's attributes, scroll down "Break Formatting" set of properties and set break to "First column".

If I were you, I'd use this option.

Query itself is also simpler, no need for any kind of aggregates:

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;
于 2020-06-20T12:09:39.597 回答
0

Going through your query, it seems like solution can be put blank except one record in class_day column per 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
于 2020-06-20T14:42:51.643 回答