一个sql语句求助

HZ23 2020-09-18 11:23:14
我有一张表如下所示:
productBar为产品编码,step为组装序号,timeUsed为组装用时。
也就是一个产品必须要经过1,2,3,4个步骤,才算组装成功,像2001000001为成功,2001000002为失败。
我的问题是:
1、如何用sql语句查出那些编码是成功的以及总的组装用时;
2、那些编码是失败的;

谢谢各位!
...全文
5016 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
夜空的温柔 2020-09-21
  • 打赏
  • 举报
回复
早点看到好了
超人小冰 2020-09-19
  • 打赏
  • 举报
回复
1 . 哪些编码成功及用时 select productBar,count(*) as count ,sum(timeUsed) from table group by productBar having count = 4 2. 哪些编码是失败的 select productBar from (select productBar,count(*) as count from table group by productBar having count < 4) as temp
tianfang 2020-09-19
  • 打赏
  • 举报
回复
不建议用sql做 可以etl或java代码实现
Ianguoxy 2020-09-19
  • 打赏
  • 举报
回复
看你业务,step安装顺序必须1234的话 可以直接根据step 判断4为成功,反之失败的就可以通过step4判断,如果step的可以乱序 那就按count把

51,397

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧