数据库
首页 > 数据库> > SQL-003查询出批次档案中重复且有库存的批次信息

SQL-003查询出批次档案中重复且有库存的批次信息

作者:互联网

/*注:以下查询语句直接运行,对执行完毕检查批次行,对于全数字的信息,在系统中检查。
查询结果显示:批次号,库存数量,存货名称*/
  SELECT sb.vbatchcode, ro.NONHANDNUM, bi.INVNAME
    FROM scm_batchcode sb
         INNER JOIN bd_invbasdoc bi ON sb.PK_INVBASDOC = bi.PK_INVBASDOC
         LEFT JOIN rmb_onhandnum ro ON sb.vbatchcode = ro.vbatchcode
   WHERE     (sb.vbatchcode IN (  SELECT ssb.vbatchcode
                                    FROM scm_batchcode ssb
                                GROUP BY ssb.vbatchcode
                                  HAVING COUNT (ssb.vbatchcode) > 1))
         AND ro.NONHANDNUM > 0
         AND length(sb.vbatchcode)>6
ORDER BY sb.vbatchcode DESC

 

标签:ro,批次,bi,003,SQL,sb,vbatchcode,ssb
来源: https://www.cnblogs.com/Chengjr/p/14103782.html