with t as (SELECT stcd,to_char(tm,'yyyymmdd') tm_1,sum(drp) drps FROM st_pptn_r where to_char(tm,'yyyymmdd')='20140929' group by stcd,to_char(tm,'yyyymmdd')) SELECT t.* FROM t ,st_pptn_r a where t.drps<>a.dyp and t.tm_1=a.tm and a.dyp is not null;
select into 执行的时候要求结果必须能查询出有且仅有1条数据,否则或报0行或多行的错误 按你现在的代码逻辑应该是有问题,因为有问题的监测站可能没有也可能有多个,按你这个写法都会报错的
(SELECT stcd,to_char(tm,'yyyymmdd') tm_1,sum(drp) drps FROM st_pptn_r
where to_char(tm,'yyyymmdd')='20140929'
group by stcd,to_char(tm,'yyyymmdd'))
SELECT t.* FROM t ,st_pptn_r a
where t.drps<>a.dyp and t.tm_1=a.tm and a.dyp is not null;
按你现在的代码逻辑应该是有问题,因为有问题的监测站可能没有也可能有多个,按你这个写法都会报错的