這段語句可不可以寫成存儲過程?
select sub.stpono, mas.teamcode, sub.itemname, subs.specs, sub.cunit,
sum(subs.ordqty) ordqty, sum(isnull(subs.outqty, 0)) outqty,subs.seg, subs.seq
from pomast mas, poitem sub, poitmdtl subs where isnull(sub.stpono,'') <> ''
and mas.pono=sub.pono
and sub.pono=subs.pono
and sub.seg=subs.seg
and subs.pono like 'ST%'group by sub.stpono, mas.teamcode, sub.itemname, subs.specs, sub.cunit,subs.seg, subs.seq
select sub.stpono, mas.teamcode, sub.itemname, subs.specs, sub.cunit,
sum(subs.ordqty) ordqty, sum(isnull(subs.outqty, 0)) outqty,subs.seg, subs.seq
from pomast mas, poitem sub, poitmdtl subs where isnull(sub.stpono,'') <> ''
and mas.pono=sub.pono
and sub.pono=subs.pono
and sub.seg=subs.seg
and subs.pono like 'ST%'group by sub.stpono, mas.teamcode, sub.itemname, subs.specs, sub.cunit,subs.seg, subs.seq
as
select sub.stpono, mas.teamcode, sub.itemname, subs.specs, sub.cunit,
sum(subs.ordqty) ordqty, sum(isnull(subs.outqty, 0)) outqty,subs.seg, subs.seq
from pomast mas, poitem sub, poitmdtl subs
where isnull(sub.stpono,'') <> ''
and mas.pono=sub.pono
and sub.pono=subs.pono
and sub.seg=subs.seg
and subs.pono like 'ST%'
group by sub.stpono, mas.teamcode, sub.itemname,
subs.specs, sub.cunit,subs.seg, subs.seq
go
as
select sub.stpono, mas.teamcode, sub.itemname, subs.specs, sub.cunit,
sum(subs.ordqty) ordqty, sum(isnull(subs.outqty, 0)) outqty,subs.seg, subs.seq
from pomast mas, poitem sub, poitmdtl subs where isnull(sub.stpono,'') <> ''
and mas.pono=sub.pono
and sub.pono=subs.pono
and sub.seg=subs.seg
and subs.pono like 'ST%'group by sub.stpono, mas.teamcode, sub.itemname, subs.specs, sub.cunit,subs.seg, subs.seqgo