i am try to select effect_dt which is in the future from eventsi table where eventsi.comments = 'rate', but before i do that, i have to check if the mose recent effect_dt is in the past in the event table, if so i have to select the effect_dt from eventsi table where eventsi.comments= 'principal', will i be able to do that in sql? i've written the code as beblow, but select nothing. really appreciate if anyone would help me out. Thanks a lot!
select deals.ID, eventsi.effect_dt
FROM deals, event, eventsi
WHERE deals.ID= eventsi.ID AND
effecti.effect_dt =
(SELECT MIN(eventsi.effect_dt)
FROM eventsi
WHERE (
(eventsi.effect-dt > = CURRENT DATE)AND
(eventsi.ID = deals.ID) AND
(eventsi.comments = 'RATE') OR
((SELECT MAX(event.effect_dt)
FROM event
WHERE event.commencts = 'RATE') <
CURRENT DATE
AND eventsi.comments = 'PRICIPAL'
AND eventsi.ID = event.ID
)
)
)
select deals.ID, eventsi.effect_dt
FROM deals, event, eventsi
WHERE deals.ID= eventsi.ID AND
effecti.effect_dt =
(SELECT MIN(eventsi.effect_dt)
FROM eventsi
WHERE (
(eventsi.effect-dt > = CURRENT DATE)AND
(eventsi.ID = deals.ID) AND
(eventsi.comments = 'RATE') OR
((SELECT MAX(event.effect_dt)
FROM event
WHERE event.commencts = 'RATE') <
CURRENT DATE
AND eventsi.comments = 'PRICIPAL'
AND eventsi.ID = event.ID
)
)
)