Ola pessoal.
To com uma dificuldade em sql, se alguem puder dar um help agradeco muitissimo.
Tenho uma query que ja funciona (Abaixo1) e preciso acrescentar nessa query o trecho (Abaixo2): Em pratica preciso acrescentar o campo A.cd_user que sai do resultado da query ABAIXO2 na query ABAIXO1. Integrar as duas para funcionar/rodar juntas.
ABAIXO1:
select * from (
select ct.cd_user, u.email, ct.creation_date data_sostituzione,
case
when b.code is not null then 'BASE'
when t.code is not null then 'MULTI'
else 'N.A.'
end as tipo, ct.code as codice
from autenti u
join JCOL.bto_code_tracking ct on u.cd_user = ct.cd_user
left join JCOL.bto_codice_base b on b.code = ct.code
left join JCOL.bto_codice_tripack t on t.code = ct.code
union
select bu.cd_user, u.email, null as data_sostituzione,
case
when b.code is not null then 'BASE'
when t.code is not null then 'MULTI'
else 'N.A.'
end as tipo, bu.code as codice
from autenti u
join JCOL.bto_utente bu on bu.cd_user = u.cd_user
left join JCOL.bto_codice_base b on b.code = bu.code
left join JCOL.bto_codice_tripack t on t.code = bu.code
);
ABAIXO2:
select A.cd_user from out_message_recipient A, out_message_header B
where A.cd_user like 'COL_BAR%'
and (B.message like 'Entra%' or B.message like 'Peccat%')
union
select A.cd_user from out_message_recipient A, out_message_header B
where A.cd_user like 'CINEM%'
and A.sent_Date >= to_date('26042012','DDMMYYYY')
and (B.message like 'Entra%' or B.message like 'Peccat%')
Abs e obrigado
ERMelo