Good afternoon!
I did it differently and it worked.
Thanks
select
solic_lib.nm_patient,
solic_lib.ds_age,
solic_lib.ds_sex,
solic_lib.NR_PRONTUARIO,
solic_lib.DS_ANOS_MESES,
solic_lib.DT_NASCIMENTO,
solic_lib.nr_prescription,
solic_lib.nr_attendance,
solic_lib.ds_tipo_service,
solic_lib.ds_convenio,
solic_lib.dt_input,
solic_lib.Npp data_prescription,
solic_lib.nm_unit,
solic_lib.ds_setor_atendimento,
solic_lib.nr_crm,
solic_lib.nm_medico,
solic_lib.nm_EXAME,
ap_res.ds_exame_bloqueado STATUS_EXAME,
ap_res.ds_motivo_recoleta,
solic_lib.TUBETE,
solic_lib.ds_status,
solic_lib.ds_usuario,
solic_lib.dt data_update,
ap_res.ds_status,
ap_res.ds_usuario,
ap_res.dt date updated,
dig_res.ds_status,
dig_res.ds_usuario,
dig_res.dt updated date,
teste_res.ds_status,
teste_res.ds_usuario,
teste_res.dt data_update,
test_res1.ds_status,
teste_res1.ds_user,
teste_res1.dt data_update,
test_res2.ds_status,
teste_res2.ds_user,
teste_res2.dt date_update
from
(select
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi') dt_input,
' '|e. nm_unit nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_person
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90) ds_status,
a. nm_usuario,
b. ds_usuario,
max (a.nr_sequencia) as nr,
max (TO_CHAR(c.DT_PRESCRICAO, 'dd/mm/yyyy hh24:mi')) as Npp,
max (to_char(a.dt_update,('dd/mm/yyyy hh24:mi:ss'))) as dt,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90) ds_motivo_recoleta,
'00' || d.nr_prescricao || ’M' || O.nr_sequencia TUBETE,
n. nr_seq_exam
FROM
prescr_proc_a step,
user b,
prescr_medica c,
prescribe procedure d,
patient care and,
personal fitness g,
doctor m,
exam_laboratorio n,
material_exame_lab o
WHERE
upper(a.nm_user) = upper(b.nm_user(+))
and a.nr_prescription IN (87935)
and a.ie_step = 10
and d.cd_motive_low = 1
and a.nr_prescription = c.nr_prescription
and c.nr_prescription = d.nr_prescription
and e.nr_attendance = c.nr_attendance
and c.cd_medico = g.cd_personal
and m.cd_person physical = g.cd_person physical
and d.nr_seq_exame = n.nr_seq_exame
-- AND ( ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) OR ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) )
AND d.ie_horario_susp = 'N'
and o.nr_sequence = obten_mat_exame_lab_prescr(d.nr_prescription, d.nr_sequence, 1)
and a.nr_seq_prescription = 1
group by
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi'),
' '|e. nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_physical person,
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90),
a. nm_usuario,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90),
'00' || d.nr_prescricao || ’M' || O.nr_sequencia,
n. nr_seq_exam,
b. ds_usuario) solic_lib,
(select
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi') dt_input,
' '|e. nm_unit nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_person
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90) ds_status,
a. nm_usuario,
b. ds_usuario,
max (a.nr_sequencia) as nr,
max (TO_CHAR(c.DT_PRESCRICAO, 'dd/mm/yyyy hh24:mi')) as Npp,
max (to_char(a.dt_update,('dd/mm/yyyy hh24:mi:ss'))) as dt,
max (decode(a.ie_exame_bloqueado,'S','Bloqueado', decode(a.ie_exame_bloqueado,'R','Repetição', decode(obter_se_recoleta_proc_etapa(a.nr_prescricao,a.nr_seq_prescricao,a.nr_sequencia),'S','Recoleta','')))) as ds_exame_bloqueado,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90) ds_motivo_recoleta,
'00' || d.nr_prescricao || ’M' || O.nr_sequencia TUBETE,
n. nr_seq_exam
FROM
prescr_proc_a step,
user b,
prescr_medica c,
prescribe procedure d,
patient care and,
personal fitness g,
doctor m,
exam_laboratorio n,
material_exame_lab o
WHERE
upper(a.nm_user) = upper(b.nm_user(+))
and a.nr_prescription IN (87935)
and a.ie_step = 20
and d.cd_motive_low = 1
and a.nr_prescription = c.nr_prescription
and c.nr_prescription = d.nr_prescription
and e.nr_attendance = c.nr_attendance
and c.cd_medico = g.cd_personal
and m.cd_person physical = g.cd_person physical
and d.nr_seq_exame = n.nr_seq_exame
-- AND ( ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) OR ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) )
AND d.ie_horario_susp = 'N'
and o.nr_sequence = obten_mat_exame_lab_prescr(d.nr_prescription, d.nr_sequence, 1)
and a.nr_seq_prescription = 1
group by
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi'),
' '|e. nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_physical person,
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90),
a. nm_usuario,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90),
'00' || d.nr_prescricao || ’M' || O.nr_sequencia,
n. nr_seq_exam,
b. ds_usuario) ap_res,
(select
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi') dt_input,
' '|e. nm_unit nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_person
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90) ds_status,
a. nm_usuario,
b. ds_usuario,
max (a.nr_sequencia) as nr,
max (TO_CHAR(c.DT_PRESCRICAO, 'dd/mm/yyyy hh24:mi')) as Npp,
max (to_char(a.dt_update,('dd/mm/yyyy hh24:mi:ss'))) as dt,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90) ds_motivo_recoleta,
'00' || d.nr_prescricao || ’M' || O.nr_sequencia TUBETE,
n. nr_seq_exam
FROM
prescr_proc_a step,
user b,
prescr_medica c,
prescribe procedure d,
patient care and,
personal fitness g,
doctor m,
exam_laboratorio n,
material_exame_lab o
WHERE
upper(a.nm_user) = upper(b.nm_user(+))
and a.nr_prescription IN (87935)
and a.ie_step = 25
and d.cd_motive_low = 1
and a.nr_prescription = c.nr_prescription
and c.nr_prescription = d.nr_prescription
and e.nr_attendance = c.nr_attendance
and c.cd_medico = g.cd_personal
and m.cd_person physical = g.cd_person physical
and d.nr_seq_exame = n.nr_seq_exame
-- AND ( ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) OR ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) )
AND d.ie_horario_susp = 'N'
and o.nr_sequence = obten_mat_exame_lab_prescr(d.nr_prescription, d.nr_sequence, 1)
and a.nr_seq_prescription = 1
group by
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi'),
' '|e. nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_physical person,
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90),
a. nm_usuario,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90),
'00' || d.nr_prescricao || ’M' || O.nr_sequencia,
n. nr_seq_exam,
b. ds_usuario) dig_res,
(select
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi') dt_input,
' '|e. nm_unit nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_person
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90) ds_status,
a. nm_usuario,
b. ds_usuario,
max (a.nr_sequencia) as nr,
max (TO_CHAR(c.DT_PRESCRICAO, 'dd/mm/yyyy hh24:mi')) as Npp,
max (to_char(a.dt_update,('dd/mm/yyyy hh24:mi:ss'))) as dt,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90) ds_motivo_recoleta,
'00' || d.nr_prescricao || ’M' || O.nr_sequencia TUBETE,
n. nr_seq_exam
FROM
prescr_proc_a step,
user b,
prescr_medica c,
prescribe procedure d,
patient care and,
personal fitness g,
doctor m,
exam_laboratorio n,
material_exame_lab o
WHERE
upper(a.nm_user) = upper(b.nm_user(+))
and a.nr_prescription IN (87935)
and a.ie_step = 30
and d.cd_motive_low = 1
and a.ie_exame_blocked <> 'R'
and a.nr_prescription = c.nr_prescription
and c.nr_prescription = d.nr_prescription
and e.nr_attendance = c.nr_attendance
and c.cd_medico = g.cd_personal
and m.cd_person physical = g.cd_person physical
and d.nr_seq_exame = n.nr_seq_exame
-- AND ( ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) OR ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) )
AND d.ie_horario_susp = 'N'
and o.nr_sequence = obten_mat_exame_lab_prescr(d.nr_prescription, d.nr_sequence, 1)
and a.nr_seq_prescription = 1
group by
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi'),
' '|e. nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_physical person,
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90),
a. nm_usuario,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90),
'00' || d.nr_prescricao || ’M' || O.nr_sequencia,
n. nr_seq_exam,
b. ds_usuario) teste_res,
(select
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi') dt_input,
' '|e. nm_unit nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_person
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90) ds_status,
a. nm_usuario,
b. ds_usuario,
max (a.nr_sequencia) as nr,
max (TO_CHAR(c.DT_PRESCRICAO, 'dd/mm/yyyy hh24:mi')) as Npp,
max (to_char(a.dt_update,('dd/mm/yyyy hh24:mi:ss'))) as dt,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90) ds_motivo_recoleta,
'00' || d.nr_prescricao || ’M' || O.nr_sequencia TUBETE,
n. nr_seq_exam
FROM
prescr_proc_a step,
user b,
prescr_medica c,
prescribe procedure d,
patient care and,
personal fitness g,
doctor m,
exam_laboratorio n,
material_exame_lab o
WHERE
upper(a.nm_user) = upper(b.nm_user(+))
and a.nr_prescription IN (87935)
and a.ie_step = 35
and d.cd_motive_low = 1
and a.ie_exame_blocked <> 'R'
and a.nr_prescription = c.nr_prescription
and c.nr_prescription = d.nr_prescription
and e.nr_attendance = c.nr_attendance
and c.cd_medico = g.cd_personal
and m.cd_person physical = g.cd_person physical
and d.nr_seq_exame = n.nr_seq_exame
-- AND ( ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) OR ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) )
AND d.ie_horario_susp = 'N'
and o.nr_sequence = obten_mat_exame_lab_prescr(d.nr_prescription, d.nr_sequence, 1)
and a.nr_seq_prescription = 1
group by
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi'),
' '|e. nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_physical person,
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90),
a. nm_usuario,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90),
'00' || d.nr_prescricao || ’M' || O.nr_sequencia,
n. nr_seq_exam,
b. ds_usuario) teste_res1,
(select
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi') dt_input,
' '|e. nm_unit nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_person
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90) ds_status,
a. nm_usuario,
b. ds_usuario,
max (a.nr_sequencia) as nr,
max (TO_CHAR(c.DT_PRESCRICAO, 'dd/mm/yyyy hh24:mi')) as Npp,
max (to_char(a.dt_update,('dd/mm/yyyy hh24:mi:ss'))) as dt,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90) ds_motivo_recoleta,
'00' || d.nr_prescricao || ’M' || O.nr_sequencia TUBETE,
n. nr_seq_exam
FROM
prescr_proc_a step,
user b,
prescr_medica c,
prescribe procedure d,
patient care and,
personal fitness g,
doctor m,
exam_laboratorio n,
material_exame_lab o
WHERE
upper(a.nm_user) = upper(b.nm_user(+))
and a.nr_prescription IN (87935)
and a.ie_step = 40
and d.cd_motive_low = 1
and a.ie_exame_blocked <> 'R'
and a.nr_prescription = c.nr_prescription
and c.nr_prescription = d.nr_prescription
and e.nr_attendance = c.nr_attendance
and c.cd_medico = g.cd_personal
and m.cd_person physical = g.cd_person physical
and d.nr_seq_exame = n.nr_seq_exame
-- AND ( ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) OR ( c.DT_PRESCRICAO BETWEEN :dt_initial AND :dt_final ) )
AND d.ie_horario_susp = 'N'
and o.nr_sequence = obten_mat_exame_lab_prescr(d.nr_prescription, d.nr_sequence, 1)
and a.nr_seq_prescription = 1
group by
n. NM_EXAME,
e. nm_patient,
a. nr_prescription,
e. ds_age,
e. ds_sex,
e. NR_PRONTUARIO,
e. DS_ANOS_MESES,
e. DT_NASCIMENTO,
e. nr_attendance,
e. ds_tipo_service,
e. ds_convenio,
TO_CHAR(e.dt_input, 'dd/mm/yyyy hh24:mi'),
' '|e. nm_unit,
e. cd_unit,
e. ds_setor_service,
m.nr_crm,
g.nm_physical person,
a. ie_stage,
a. nr_seq_prescription,
substr(Obten_valor_dominio_status_lis(a.ie_step),1,90),
a. nm_usuario,
substr(lab_obten_desc_motivo_recoleta(d.nr_seq_recoleta),1,90),
'00' || d.nr_prescricao || ’M' || O.nr_sequencia,
n. nr_seq_exam,
b. ds_usuario) teste_res2
Where
solic_lib.nr_prescricao = ap_res.nr_prescricao
and solic_lib.nr_prescription = dig_res.nr_prescription
and solic_lib.nr_prescription = teste_res.nr_prescription
and solic_lib.nr_prescription = teste_res1.nr_prescription
and solic_lib.nr_prescription = test_res2.nr_prescription
and ap_res.nr_prescription = solic_lib.nr_prescription
and ap_res.nr_prescricao = dig_res.nr_prescricao
and ap_res.nr_prescricao = teste_res.nr_prescricao
and ap_res.nr_prescription = teste_res1.nr_prescription
and ap_res.nr_prescription = teste_res2.nr_prescription
and dig_res.nr_prescription = solic_lib.nr_prescription
and dig_res.nr_prescricao = ap_res.nr_prescricao
and dig_res.nr_prescricao = teste_res.nr_prescricao
and dig_res.nr_prescription = teste_res1.nr_prescription
and dig_res.nr_prescription = teste_res2.nr_prescription
and teste_res.nr_prescription = solic_lib.nr_prescription
and teste_res.nr_prescricao = ap_res.nr_prescricao
and teste_res.nr_prescricao = dig_res.nr_prescricao
and teste_res.nr_prescricao = teste_res1.nr_prescricao
and teste_res.nr_prescricao = teste_res2.nr_prescricao
and teste_res1.nr_prescription = solic_lib.nr_prescription
and teste_res1.nr_prescription = ap_res.nr_prescription
and teste_res1.nr_prescription = dig_res.nr_prescription
and teste_res1.nr_prescricao = teste_res.nr_prescricao
and teste_res1.nr_prescription = teste_res2.nr_prescription
and teste_res2.nr_prescription = solic_lib.nr_prescription
and teste_res2.nr_prescription = ap_res.nr_prescription
and teste_res2.nr_prescription = dig_res.nr_prescription
and teste_res2.nr_prescricao = teste_res.nr_prescricao
and teste_res2.nr_prescription = teste_res1.nr_prescription
and solic_lib.nr_seq_prescription = ap_res.nr_seq_prescription
and solic_lib.nr_seq_prescription = dig_res.nr_seq_prescription
and solic_lib.nr_seq_prescription = teste_res.nr_seq_prescription
and solic_lib.nr_seq_prescription = test_res1.nr_seq_prescription
and solic_lib.nr_seq_prescription = test_res2.nr_seq_prescription
and ap_res.nr_seq_prescription = solic_lib.nr_seq_prescription
and ap_res.nr_seq_prescricao = dig_res.nr_seq_prescricao
and ap_res.nr_seq_prescricao = teste_res.nr_seq_prescricao
and ap_res.nr_seq_prescription = teste_res1.nr_seq_prescription
and ap_res.nr_seq_prescription = teste_res2.nr_seq_prescription
and dig_res.nr_seq_prescription = solic_lib.nr_seq_prescription
and dig_res.nr_seq_prescription = ap_res.nr_seq_prescription
and dig_res.nr_seq_prescricao = teste_res.nr_seq_prescricao
and dig_res.nr_seq_prescription = teste_res1.nr_seq_prescription
and dig_res.nr_seq_prescription = test_res2.nr_seq_prescription
and teste_res.nr_seq_prescription = solic_lib.nr_seq_prescription
and teste_res.nr_seq_prescricao = ap_res.nr_seq_prescricao
and teste_res.nr_seq_prescricao = dig_res.nr_seq_prescricao
and teste_res.nr_seq_prescricao = teste_res1.nr_seq_prescricao
and teste_res.nr_seq_prescricao = teste_res2.nr_seq_prescricao
and teste_res1.nr_seq_prescription = solic_lib.nr_seq_prescription
and teste_res1.nr_seq_prescription = ap_res.nr_seq_prescription
and teste_res1.nr_seq_prescription = dig_res.nr_seq_prescription
and teste_res1.nr_seq_prescription = teste_res.nr_seq_prescription
and teste_res1.nr_seq_prescription = teste_res2.nr_seq_prescription
and teste_res2.nr_seq_prescription = solic_lib.nr_seq_prescription
and teste_res2.nr_seq_prescription = ap_res.nr_seq_prescription
and teste_res2.nr_seq_prescription = dig_res.nr_seq_prescription
and teste_res2.nr_seq_prescription = teste_res.nr_seq_prescription
and teste_res2.nr_seq_prescription = teste_res1.nr_seq_prescription
and solic_lib.nr_seq_exame = ap_res.nr_seq_exame
and solic_lib.nr_seq_exame = dig_res.nr_seq_exame
and solic_lib.nr_seq_exame = teste_res.nr_seq_exame
and solic_lib.nr_seq_exame = teste_res1.nr_seq_exame
and solic_lib.nr_seq_exame = teste_res2.nr_seq_exame
and ap_res.nr_seq_exame = solic_lib.nr_seq_exame
and ap_res.nr_seq_exame = dig_res.nr_seq_exame
and ap_res.nr_seq_exame = teste_res.nr_seq_exame
and ap_res.nr_seq_exame = teste_res1.nr_seq_exame
and ap_res.nr_seq_exame = teste_res2.nr_seq_exame
and dig_res.nr_seq_exame = solic_lib.nr_seq_exame
and dig_res.nr_seq_exame = ap_res.nr_seq_exame
and dig_res.nr_seq_exame = teste_res.nr_seq_exame
and dig_res.nr_seq_exame = teste_res1.nr_seq_exame
and dig_res.nr_seq_exame = teste_res2.nr_seq_exame
and teste_res.nr_seq_exame = solic_lib.nr_seq_exame
and teste_res.nr_seq_exame = ap_res.nr_seq_exame
and teste_res.nr_seq_exame = dig_res.nr_seq_exame
and teste_res.nr_seq_exame = teste_res1.nr_seq_exame
and teste_res.nr_seq_exame = teste_res2.nr_seq_exame
and teste_res1.nr_seq_exame = solic_lib.nr_seq_exame
and teste_res1.nr_seq_exame = ap_res.nr_seq_exame
and teste_res1.nr_seq_exame = dig_res.nr_seq_exame
and teste_res1.nr_seq_exame = teste_res.nr_seq_exame
and teste_res1.nr_seq_exame = teste_res2.nr_seq_exame
and teste_res2.nr_seq_exame = solic_lib.nr_seq_exame
and teste_res2.nr_seq_exame = ap_res.nr_seq_exame
and teste_res2.nr_seq_exame = dig_res.nr_seq_exame
and teste_res2.nr_seq_exame = teste_res.nr_seq_exame
and teste_res2.nr_seq_exame = teste_res1.nr_seq_exame
ORDER BY 11, 1, 7
At first I see that your select returns several columns (a.nr_prescription, ds_status, etc.). Maybe if you explained better what you want (an example could be enlightening) you could get help.
– anonimo
Yes, Are 5 status (Request released, Collected, Received Lab, Typing of the result, Approval of the result, Clearance of the exam) of the same prescription (a.nr_prescription), need to come out in column (side by side), not as in the image below one another.
– Renan Kawamoto Fagundes
Search for the LISTAGG aggregation function along with the GROUP BY clause.
– anonimo
https://www.oracle.com/br/technical-resources/articles/pivot-andunpivot-feature-oracle-db.html https://glufke.net/oracle/viewtopic.php?t=9819 "pivot" may be by pivot itself or "case" see examples.
– Motta
Using LISTAGG, you still did not group ... SELECT e. nm_paciente,
LISTAGG (substr(Obter_Valor_Dominio_Status_LIS(a.ie_etapa),1,90) ||' - '|| to_char(a.dt_atualizacao,('dd/mm/yyyy hh24:mi:ss')),';') WITHIN GROUP (ORDER BY a.ie_etapa, a.dt_atualizacao) A
 
FROM prescr_proc_step a, user b, prescr_medica c, prescr_procedure d, attendance_patient_v e, personal g, doctor m
– Renan Kawamoto Fagundes
WHERE 

upper(a.nm_usuario) = upper(b.nm_usuario(+))
and a.nr_prescricao = 85724
and a.nr_seq_prescricao = 1

-- and ie_etapa = 10

and a.nr_prescricao = c.nr_prescricao
and c.nr_prescricao = d.nr_prescricao
and e.nr_attendance = c.nr_attendance and c.cd_medico = g.cd_personal Physique and m.cd_personal Physique = g.cd_personal Physique GROUP BY e. nm_patient, a.dt_update ORDER BY e. nm_patient, a.dt_update
– Renan Kawamoto Fagundes