品种
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
转载于:https://blog.51cto.com/bks2015/1889804
本文介绍了一种使用SQL进行批量查询的方法,通过多个SELECT语句组合实现对特定批次和品种的数据筛选与汇总。其中包括了对品种、批号及小批号等字段的详细统计,如品种数量为3146种,批号总数为4838个等。

被折叠的 条评论
为什么被折叠?



