天天看點

庫房分析資料

品種

select distinct spid from sphwph where hw in ('HWI00000008','HWI00000003') and shl>0

批号

select distinct pihao,spid into #1 from sphwph where hw in ('HWI00000008','HWI00000003') and shl>0 order by spid

select spid from #1 group by spid having count(spid)>1

select spid from #1 group by spid having count(spid)>2

select spid from #1 group by spid having count(spid)>3

select spid from #1 group by spid having count(spid)>4

合起來的小批号

select spid,pihao,sum(shl) shl into #2 from sphwph where hw in ('HWI00000008','HWI00000003') and shl<>0 group by spid,pihao

select distinct pihao,spid from #2 where  shl>0 and shl<10  order by spid

散貨品種有3146,批号共有4838,大于1的有1135,大于2的有372大于3的有124大于4的是37,小批号的1766

本文轉自 qvodnet 51CTO部落格,原文連結:http://blog.51cto.com/bks2015/1889804

繼續閱讀