ArtNick, попробуй тоже самое написать с пивотом
with t1 as (
select 'Петя' name, 'Мальчик' gender from dual union all
select 'Даша', 'Девочка' from dual
),
t2 as (
select 'Петя' name, 1 less_num, 'Математика' lesson from dual union all
select 'Петя', 2, 'Русский' from dual union all
select 'Даша', 1, 'Английский' from dual union all
select 'Даша', 2, 'Физкультура' from dual
)
select t1.name, gender,
1 less_num_1, max(decode(less_num, 1, lesson)) lesson_1,
2 less_num_2, max(decode(less_num, 2, lesson)) lesson_2
from t1, t2
where t1.name = t2.name
group by t1.name, gender