WITH a AS (select 'petrov' doctor, 'ivanov' client, 11 TIME FROM dual
UNION
select 'petrov' doctor,'ivanov2' client, 12 TIME FROM dual
UNION
select 'petrov' doctor, 'ivanov3' client, 13 TIME FROM dual
),
b AS (select 'petrov' doctor, 'ivanov' client, 11 TIME FROM dual
UNION
select 'petrov2' doctor, 'ivanov' client, 12 TIME FROM dual
UNION
SELECT 'petrov3' doctor, 'ivanov' client, 13 TIME FROM dual
UNION
SELECT 'petrov4' doctor, 'ivanov' client, 14 TIME FROM dual
UNION
select 'petrov' doctor, 'ivanov2' client, 12 TIME FROM dual
UNION
select 'petrov' doctor, 'ivanov3' client, 13 TIME FROM dual
UNION
SELECT 'petrov3' doctor, 'ivanov3' client, 14 TIME FROM dual)
SELECT a.doctor,b.client,b.doctor,b.time
FROM a,b
WHERE a.doctor(+)=b.doctor
AND a.client(+)=b.client
ORDER BY b.client,b.doctor
DOCTOR CLIENT DOCTOR TIME
1 petrov ivanov petrov 11
2 ivanov petrov2 12
3 ivanov petrov3 13
4 ivanov petrov4 14
5 petrov ivanov2 petrov 12
6 petrov ivanov3 petrov 13
7 ivanov3 petrov3 14