declare num integer;
begin
select count(distinct userid) into num from user_info_t t where to_char(regdate,'yyyymm')='200802';select count(distinct userid)/num from mmwarehome.user_log_t 
where userid in (select userid from user_info_t t where to_char(regdate,'yyyymm')='200802');
end;

解决方案 »

  1.   

    select count(distinct userid)/num from mmwarehome.user_log_t  
    where userid in (select userid from user_info_t t where to_char(regdate,'yyyymm')='200802'); 
    这里少了个INTO 
    再定义个变量
    declare num integer; 
    declare temp integer; begin 
    select count(distinct userid) into num from user_info_t t where to_char(regdate,'yyyymm')='200802'; select count(distinct userid)/num into temp from mmwarehome.user_log_t  
    where userid in (select userid from user_info_t t where to_char(regdate,'yyyymm')='200802'); 
    end;
      

  2.   

    楼上回答完全正确,隐式游标必须有into去赋值!