Sql case when

复制代码
select 跟踪单号 , b.pm,b.sh,b.wkgg,b.wbxh,b.ljxh,b.khmc,b.chcpmc,b.ms, sum(case when 生产部门='打包' then 1 else 0 end ) 打包,
sum(case when 生产部门= '二次曝光' then 1 else 0 end)二次曝光,
sum(case when 生产部门= '膜厚' then 1 else 0 end)膜厚,
sum(case when 生产部门= '晒版' then 1 else 0 end)晒版,
sum(case when 生产部门= '物控' then 1 else 0 end)物控 ,
sum(case when 生产部门= '涂布' then 1 else 0 end)涂布 ,
sum(case when 生产部门= '脱脂' then 1 else 0 end)脱脂,
sum(case when 生产部门= '显影' then 1 else 0 end)显影,
sum(case when 生产部门= '一检' then 1 else 0 end)一检

from 生产 a ,wbgzd b where 在手='0' and 生产部门 not in('物控仓库','物控') and a.跟踪单号=b.gzdh group by 跟踪单号 , b.pm,b.sh,b.wkgg,b.wbxh,b.ljxh,b.khmc,b.chcpmc,b.ms
复制代码

 

posted @   不买南孚电池  阅读(336)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
点击右上角即可分享
微信分享提示