I've got the following code [thanks to Gordon Linoff]:
select (case when n.n = 1 then column1 else 'END' end) as column1,
(case when n.n = 1 then firsttime else lasttime end) as "time"
from (select column1, min(time) as firsttime, max(time) as lasttime
from t
group by column1
) t cross join
(select 1 as n from dual union all select 2 from dual) n
order by column1, n.n;
there are more columns in table "t" so I'm trying to bring them with the following query:
select (case when n.n = 1 then column1 else 'END' end) as column1,
(case when n.n = 1 then firsttime else lasttime end) as "time",
column2, column3
from (select column1,column2,column3, min(time) as firsttime, max(time) as lasttime
from t
group by column1
) t cross join
(select 1 as n from dual union all select 2 from dual) n
order by column1, n.n;
but "ORA-00979: not a GROUP BY expression
" is the output.