Hi all
In Apex 20.1
Am performing this query for an Interactive Report to use in a subscription.
select p.poliza_id,
s.owner
from risk_polizas p, risk_clientes c, risk_riesgos r, risk_companias ag, risk_companias co, global_usuarios u join APEX_APPLICATION_PAGE_IR_SUB s on s.owner = upper(u.username)
where p.cliente_id = c.cliente_id
and p.riesgo_id = r.riesgo_id
and p.agencia_id = ag.compania_id
and p.compania_id = co.compania_id
and p.norenovar <> 'Y'
and nvl(r.norenovar,'N') <> 'Y'
and p.prima <> 0
and p.expiracion between trunc(sysdate, 'MONTH') and LAST_DAY(sysdate)
and p.organizacion_id = u.organizacion_id
I need to know which user created the subscription so I can do the query inside the organization he belongs to.
So I do a join between my users tables, which have the user organization, and the APEX_APPLICATION_PAGE_IR_SUB table that hold the user who created the subscription.
The problem is that this query is returning duplicates records.
Is returning records from the risk_polizas table for each record in the APEX_APPLICATION_PAGE_IR.
So if the query is suppose to return two records but if the APEX_APPLICATION_PAGE_IR has two records it returns 4 record.
One for every record in APEX_APPLICATION_PAGE_IR.
How can I fix this?
What would be the best way to perform this query?
Thanks for the help!
Javier