Subject Re: [ib-support] SubQuery with Date
Author Svein Erling Tysvaer
Hi Arvee!

If this works it will be dead slow. Avoid using a subselect as
part of IN. Rather use EXISTS:

Select FK1_AGENCY_CD ,FK2_PRODUCT_CD
,FK2_PACKAGE_CD ,ORIGN_PAX_NB
,ADD_PAX_NB ,CUTOFF_PAX_NB
,BOOKED_PAX_NB ,FK2_SCHDEPART_TRIP
,CUTOFF_DATE ,COMMENTS
From TALLOTMENT
Where EXISTS( SELECT 1 FROM TSCHED_DEPART WHERE TRIP_SEQ_NB =
FK2_SCHDEPART_TRIP and
DEPT_SCHE_STATUS = 'OPEN' AND EXISTS (SELECT 1 FROM tcutoff_rule WHERE
current_date + DAYS_BEFDEPT_NB = DEPATURE_DATE));

I'm not certain this is 100% correct since I am currently short of time and
you may have to alias a bit as well, but it should be enough to get you
going. As for your problem with not returning anything, it could be that
DEPARTURE_DATE includes information about time.

HTH,
Set