Hi Guys,I've been given a task to rewirte a bit of SQL and was wondering if you could help me out. The bit of sql below takesa while to run so any help would be greatful.
select NET_AMOUNT,UNIT_AMOUNT,QUANTITY,to_Char(PRO_ID) as ProID,to_Char(PER_ID) as PerID,to_Char(MEM_ID) as MEM_ID
from INVOICE_LINES
where exists(select 1 from calendar_periods cap where cap.id = cap_id and year_number > = to_number(to_char(sysdate,'YYYY')) - 2)
select NET_AMOUNT,UNIT_AMOUNT,QUANTITY,to_Char(PRO_ID) as ProID,to_Char(PER_ID) as PerID,to_Char(MEM_ID) as MEM_ID
from INVOICE_LINES
where exists(select 1 from calendar_periods cap where cap.id = cap_id and year_number > = to_number(to_char(sysdate,'YYYY')) - 2)