以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  [求助]  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=31140)

--  作者:ruanziming
--  发布时间:2013/4/10 19:14:00
--  [求助]
Select Distinct Top 8000 {PRINDXDD}.ID,jgzh As [加工组号],xh As [商品序号],OTHER_FL As [包装组号],fhzh As [分货组号],dlgg As [定量规格],dzxh As [袋子型号],{SPBM}.jbdw As [基本单位],processing_spmc As [原料名称],{SPBM}.dwbm As [采购员],KCSL As [净菜库存数量],finishsp_rate As [出成率],{XSDD}.SL / {SPBM}.finishsp_rate * 100 As [订单数量/出成率],processing_spbm As [原料编码],SPJC As [商品简称],RQ As [单据日期],DJBH As [单据编号],JSR As [经手人],JHRQ As [到货日期],{XSDD}.SPBM As [商品编码],{XSDD}.SL As [基本单位之数量],pack_sl As [包装单位之数量],{PACK_UNIT}.jbdw As [订货包装单位],pack_rate As [包装单位转换率],DWJC As [订货单位简称],SPMC As [商品名称],client_spmc As [客户叫法],ZY As [订单说明],KCSL/finishsp_rate*100*-1 As [库存数量],maincompany_jc As [总公司] From ((({PRINDXDD} Left JOIN {XSDD} ON {XSDD}.[ID] = {PRINDXDD}.[ID]) Inner JOIN {WLDWBM} ON {WLDWBM}.[DWBM] = {PRINDXDD}.[DWBM]) Inner JOIN {PACK_UNIT} ON {PACK_UNIT}.[pack_id] = {XSDD}.[id_unit]) Left JOIN {SPBM} ON {SPBM}.[SPBM] = {XSDD}.[SPBM] Where {PRINDXDD}.RQ = #2013-04-01# Order By RQ DESC

请哪位帮忙看看这个查询的条件如何改成最近的一天?就是看这个日期离系统日期的最近一天。

--  作者:有点甜
--  发布时间:2013/4/10 23:07:00
--  
用代码合成:
 
"Select Distinct Top 8000 {PRINDXDD}.ID,jgzh As [加工组号],xh As [商品序号],OTHER_FL As [包装组号],fhzh As [分货组号],dlgg As [定量规格],dzxh As [袋子型号],{SPBM}.jbdw As [基本单位],processing_spmc As [原料名称],{SPBM}.dwbm As [采购员],KCSL As [净菜库存数量],finishsp_rate As [出成率],{XSDD}.SL / {SPBM}.finishsp_rate * 100 As [订单数量/出成率],processing_spbm As [原料编码],SPJC As [商品简称],RQ As [单据日期],DJBH As [单据编号],JSR As [经手人],JHRQ As [到货日期],{XSDD}.SPBM As [商品编码],{XSDD}.SL As [基本单位之数量],pack_sl As [包装单位之数量],{PACK_UNIT}.jbdw As [订货包装单位],pack_rate As [包装单位转换率],DWJC As [订货单位简称],SPMC As [商品名称],client_spmc As [客户叫法],ZY As [订单说明],KCSL/finishsp_rate*100*-1 As [库存数量],maincompany_jc As [总公司] From ((({PRINDXDD} Left JOIN {XSDD} ON {XSDD}.[ID] = {PRINDXDD}.[ID]) Inner JOIN {WLDWBM} ON {WLDWBM}.[DWBM] = {PRINDXDD}.[DWBM]) Inner JOIN {PACK_UNIT} ON {PACK_UNIT}.[pack_id] = {XSDD}.[id_unit]) Left JOIN {SPBM} ON {SPBM}.[SPBM] = {XSDD}.[SPBM] Where {PRINDXDD}.RQ = #" & date.Today.Adddays(-1) & "# Order By RQ DESC"

--  作者:ruanziming
--  发布时间:2013/4/11 15:57:00
--  
谢谢。运行是报错。
第 1 行: \' & date.Today.Adddays(-1) & \' 附近有语法错误。
--  作者:ruanziming
--  发布时间:2013/4/16 11:16:00
--  
我的是SQL2000,我改了单引号后,{PRINDXDD}.RQ = \' & date.Today.Adddays(-1) & \' Order By RQ DESC   提示从字符串转换为 datetime 时发生语法错误。
--  作者:Bin
--  发布时间:2013/4/16 11:18:00
--  
不可以这样直接加..  要改为如下
{PRINDXDD}.RQ = \'" & date.Today.Adddays(-1) & "\' Order By RQ DESC

--  作者:Bin
--  发布时间:2013/4/16 11:24:00
--  
以下是引用muhua在2013-4-16 11:22:00的发言:
是把 # 改, 双引号不用改。

5楼不是说改了不行么.报错无法转换啊.
--  作者:ruanziming
--  发布时间:2013/4/16 18:58:00
--  
从字符串转换为 datetime 时发生语法错误。
Select Distinct Top 8000 {PRINDXDD}.ID,jgzh As [加工组号],xh As [商品序号],OTHER_FL As [包装组号],fhzh As [分货组号],dlgg As [定量规格],dzxh As [袋子型号],{SPBM}.jbdw As [基本单位],processing_spmc As [原料名称],{SPBM}.dwbm As [采购员],KCSL As [净菜库存数量],finishsp_rate As [出成率],{XSDD}.SL / {SPBM}.finishsp_rate * 100 As [订单数量/出成率],processing_spbm As [原料编码],SPJC As [商品简称],RQ As [单据日期],DJBH As [单据编号],JSR As [经手人],JHRQ As [到货日期],{XSDD}.SPBM As [商品编码],{XSDD}.SL As [基本单位之数量],pack_sl As [包装单位之数量],{PACK_UNIT}.jbdw As [订货包装单位],pack_rate As [包装单位转换率],DWJC As [订货单位简称],SPMC As [商品名称],client_spmc As [客户叫法],ZY As [订单说明],KCSL/finishsp_rate*100*-1 As [库存数量],maincompany_jc As [总公司] From ((({PRINDXDD} Left JOIN {XSDD} ON {XSDD}.[ID] = {PRINDXDD}.[ID]) Inner JOIN {WLDWBM} ON {WLDWBM}.[DWBM] = {PRINDXDD}.[DWBM]) Inner JOIN {PACK_UNIT} ON {PACK_UNIT}.[pack_id] = {XSDD}.[id_unit]) Left JOIN {SPBM} ON {SPBM}.[SPBM] = {XSDD}.[SPBM] Where {PRINDXDD}.RQ = \'" & date.Today.Adddays(-1) & "\' Order By RQ DESC

--  作者:ruanziming
--  发布时间:2013/4/17 12:00:00
--  
自己顶一下,问题还没解决。
--  作者:Bin
--  发布时间:2013/4/17 12:07:00
--  
做个例子发出来看看吧.我左右测试都没问题.
--  作者:ruanziming
--  发布时间:2013/4/17 12:35:00
--  
去了这个where就ok。我想写的地方没错。执行SQL啦。