SQL求助(100分)

  • 主题发起人 主题发起人 esxpd
  • 开始时间 开始时间
E

esxpd

Unregistered / Unconfirmed
GUEST, unregistred user!
已知表:<br>名称 &nbsp;入库 &nbsp;出库 &nbsp; 成本<br>a &nbsp; &nbsp; &nbsp;1<br>a &nbsp; &nbsp; &nbsp;2<br>a &nbsp; &nbsp; &nbsp;1<br>a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1<br>a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;1 <br>a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.5<br>a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.5 <br>a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.5<br>a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.5<br><br><br>如何select求出下面结果:<br>名称 &nbsp;入库 &nbsp;出库 &nbsp;成本<br>a &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; 1 &nbsp; &nbsp;0.5<br>a &nbsp; &nbsp; &nbsp;2 &nbsp; &nbsp; 1 &nbsp; &nbsp;0.5<br>a &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;0.5<br>a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 0.5
 
怎么,可能有这样的表呢?<br><br>绝对要分为 入库,出库二表的,再处理<br>的时候,好象是先进先出,做个嵌套循环<br>去处理就ok<br><br>1.for 取1入库<br>&nbsp;begin<br>&nbsp; &nbsp;for 取1出库<br>&nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp;检查是否足够(入&gt;=出)<br>&nbsp; &nbsp; &nbsp;不够 取下一条 入库 goto 1.<br>&nbsp; &nbsp; &nbsp;够了 写入 出入 表<br>&nbsp; &nbsp;end<br>end
 
只是为了减少记录,利于查看.
 
增加一 批次 列,然后按批次列汇总就行了
 
方向想错了吧。
 

Similar threads

S
回复
0
查看
846
SUNSTONE的Delphi笔记
S
S
回复
0
查看
778
SUNSTONE的Delphi笔记
S
后退
顶部