试试以下方法,采用临时表的方法,而不是使用相关子查询。select type, key2, key3, count(*) count_log from sap_capture_log group by type,key2,key3 into temp temp_count;create unique index idx_tmp_count on temp_count(type,key2,key3);select gc_id,gc_orig_store...
显示全部试试以下方法,采用临时表的方法,而不是使用相关子查询。
select type, key2, key3, count(*) count_log from sap_capture_log group by type,key2,key3 into temp temp_count;
create unique index idx_tmp_count on temp_count(type,key2,key3);
select gc_id,gc_orig_store,gc_amount,gc_type,gc_date,gc_invoice,gc_customer,'N'
from giftcert, temp_count t
where gc_date between today-7 and today-1 and gc_type="S"
and t.type="G" and gc_id=t.key2 and gc_date=t.key3 and t.count_log=0;
收起