| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Mailing Lists -> Oracle-L -> Solution for Will Weir
Hi Will,
You were right, the TRUNC-function is the problem. You can solve this by using the BETWEEN-construction. Secondly, try to use as few tables as possible in a query. Tables wich have only one record should be excluded from the query. Instead use bind-variables.
So: (if using SQL*Plus)
col tmpydat_start new_value tmpydat_start;
col tmpydat_end new_value tmpydat_end;
select tmpydat_start, tmpydat_end
from taismgr.tmpydat;
then..
select y.sbbyaps_chg_detail_code,
(y.sbbyaps_amount - x.sbbyaps_amount) sbbyaps_amount from saturn.sbbyaps x,
saturn.sbbyaps y
where x.sbbyaps_chg_detail_code = y.sbbyaps_chg_detail_code
and x.sbbyaps_pay_detail_code = y.sbbyaps_pay_detail_code
and x.sbbyaps_chg_term_code = y.sbbyaps_chg_term_code
and x.sbbyaps_pay_term_code = y.sbbyaps_pay_term_code
and x.sbbyaps_activity_date between to_date('&tmpydat_start') and
to_date('&tmpydat_end') - (1/(60*60*24)) /* minus 1 second */
.....
Good luck
Martin de Jong
Central Bureau of Statistics
Holland
MJNG_at_CBS.NL
Received on Sun Mar 19 1995 - 18:40:57 CST
![]() |
![]() |