以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]查询语句代码有点复杂,请老师帮我看看-9楼更新问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=147586) |
-- 作者:huangfanzi -- 发布时间:2020/3/19 22:37:00 -- [求助]查询语句代码有点复杂,请老师帮我看看-9楼更新问题 \'提取此页数据 Dim cmd As New SQLCommand cmd.C onnection Name = "SqlQqServer" \'记得设置数据源名称 cmd.C ommandText = "S elect Count(*) From {生产计划排单}" If flt > "" Then cmd.C ommandText = cmd.C ommandText & " where " & flt End If Dim Count As Integer = cmd.ExecuteScalar() \'获取总的行数 Dim ppyf As String \'匹配已发量 ppyf = "(s elect Sum(发货量) f rom {销售出库} b where c.通知单号 = b.通知单号 And b.状态 = \'有效\' And b.审核 = 1) As 已发量," cmd.C ommandText = "S elect * From (S elect Row_Number() Over(Order by 通知单号) As 序号, c.[_Identify],c.通知单号,c.工程名称,c.业务员,c.开盘时间 As 开盘日期,c.计划方量," & ppyf & (计划方量 - 已发量) As 待发量 & " F rom {生产计划排单} As c " If flt > "" Then cmd.C ommandText = cmd.C ommandText & " where " & flt End If cmd.C ommandText = cmd.C ommandText & ") As a " cmd.C ommandText = cmd.C ommandText & " Where 序号>= " & StartRow & " And 序号 <= " & EndRow 这个红字部分应该如何写,晕了,请蓝老师帮我写下算出待发量
[此贴子已经被作者于2020/3/22 13:03:42编辑过]
|
-- 作者:sloyy -- 发布时间:2020/3/20 1:52:00 -- & ", (C.计划方量 - C.已发量) As 待发量 F rom {生产计划排单} As c" |
-- 作者:huangfanzi -- 发布时间:2020/3/20 11:48:00 -- 请问,当结果算下来待发量为负数时,即已发量大于计划方量时,待发量的值显示0,应该如何写代码,谢谢 |
-- 作者:有点蓝 -- 发布时间:2020/3/20 12:09:00 -- & ", (case when C.计划方量 > C.已发量 then C.计划方量 - C.已发量 else 0 end ) As 待发量 F rom {生产计划排单} As c" |
-- 作者:huangfanzi -- 发布时间:2020/3/20 21:48:00 -- 请老师看下代码,刚才试了下,不行啊 .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2020.3.11.8 错误所在事件: 详细错误信息: 列名 \'已发量\' 无效。 Dim ppyf As String \'匹配已发量 ppyf = "(s elect Sum(发货量) f rom {销售出库} b where c.通知单号 = b.通知单号 And b.状态 = \'有效\' And b.审核 = 1) As 已发量," cmd.C ommandText = "S elect * From (S elect Row_Number() Over(Order by 通知单号) As 序号, c.[_Identify],c.通知单号,c.工程名称,c.业务员,c.开盘时间 As 开盘日期,c.计划方量," & ppyf & " (c.计划方量 - c.已发量) As 待发量 F rom {生产计划排单} As c "
|
-- 作者:有点蓝 -- 发布时间:2020/3/20 22:03:00 -- Dim ppyf As String \'匹配已发量 ppyf = "(s elect Sum(发货量) f rom {销售出库} b where c.通知单号 = b.通知单号 And b.状态 = \'有效\' And b.审核 = 1) As 已发量" cmd.C ommandText = "S elect *,(计划方量 - 已发量) As 待发量 From (S elect Row_Number() Over(Order by 通知单号) As 序号, c.[_Identify],c.通知单号,c.工程名称,c.业务员,c.开盘时间 As 开盘日期,c.计划方量," & ppyf & " F rom {生产计划排单} As c "
|
-- 作者:huangfanzi -- 发布时间:2020/3/20 22:17:00 -- 蓝老师,代码调试成功了,但有个问题,如何计划方量为60,当已发量空时,也就是没发过货,待发量应该是60,可实际显示也是空 |
-- 作者:有点蓝 -- 发布时间:2020/3/20 22:54:00 -- (isnull(计划方量,0) - isnull(已发量,0)) As 待发量 |
-- 作者:huangfanzi -- 发布时间:2020/3/22 8:36:00 -- 蓝老师,请再帮我写下代码,把已发量查不到时也显示0而不是空,谢谢 Dim ppyf As String \'匹配已发量 ppyf = "(s elect Sum(发货量) f rom {销售出库} b where c.通知单号 = b.通知单号 And b.状态 = \'有效\' And b.审核 = 1) As 已发量" cmd.C ommandText = "S elect *,(isnull(计划方量,0) - isnull(已发量,0)) As 待发量 From (Select Row_Number() Over(Order by 通知单号) As 序号, c.[_Identify],c.通知单号,c.工程名称,c.业务员,c.开盘时间 As 开盘日期,c.计划方量," & ppyf & " F rom {生产计划排单} As c "
|
-- 作者:有点蓝 -- 发布时间:2020/3/22 20:59:00 -- (s elect Sum(isnull(发货量,0)) f rom {销售出库} |