关闭

最初学习是所写SQL语句

498人阅读 评论(0) 收藏 举报


declare cursor c2 is select goodsid,sum(amount) amount from t_bill_detail  where exists (select bseqid from t_bill_header where billtypeid=12) group by goodsid;     
begin
          delete from t_temp_sale;
          for t2 in c2 loop
              insert into t_temp_sale (goodsid,amount) values(t2.goodsid,t2.amount);
          end loop;
end;
/     


内嵌视图:

select  t.goodsid,t.name,t.spec,t.factory,h.amount
   from (select a.goodsid,sum(amount) amount
        from t_bill_detail a where exists(select bseqid from t_bill_header where billtypeid=12 and a.bseqid=bseqid) group by(a.goodsid)) h,
   t_goods_info t where t.goodsid=h.goodsid;

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:783次
    • 积分:17
    • 等级:
    • 排名:千里之外
    • 原创:0篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档
    阅读排行