zoukankan      html  css  js  c++  java
  • 生成行号

    --mysql

    --result='yes' 没问题;result='no' 有问题

    select companyid,companyname,departmentid,warehouseid,skuid,startinventory,ininventory_hj,outinventory_hj,endinventory,createdate,result from (
    select companyid,companyname,departmentid,warehouseid,skuid,a.startinventory,ininventory_hj,outinventory_hj,endinventory,a.createdate,a.rownum,
    case when (b.createdate=DATE_add(a.createdate,INTERVAL 1 DAY) && a.endinventory=b.startinventory) || (b.createdate is null && b.rownum is null)  then 'yes' else 'no' end result
    from (
    select companyid,companyname,departmentid,warehouseid,skuid,startinventory,ininventory_hj,outinventory_hj,endinventory
    ,createdate,@rownum:=@rownum+1 as rownum
    from table,(select @rownum:=0) t
    order by createdate) a
    left join

     (
    select startinventory,createdate,@rownums:=@rownums+1 as rownum
    from table,(select @rownums:=0) t
    order by createdate) b
    on a.rownum=b.rownum-1) c
    where result='yes'
    order by createdate
  • 相关阅读:
    匈牙利算法自主总结
    luogu P2071 座位安排
    luogu P1613 跑路
    luogu P1250 种树
    luogu P1744 采购特价商品
    网络流
    其他图论
    组合计数
    小技巧
    矩阵&&高斯消元
  • 原文地址:https://www.cnblogs.com/eboss/p/4897652.html
Copyright © 2011-2022 走看看