首页 新闻 搜索 专区 学院

sybase下一下查询语句有什么问题

0
[已关闭问题]
select a.STCD,a.TM,a.Z,a.Q,a.XSA,a.XSAVV,a.XSMXV,a.FLWCHRCD,a.WPTN,a.MSQMT,a.MSAMT,a.MSVMT, b.STNM,b.RVNM,b.STLC,b.BGFRYM,c.LDKEL,c.RDKEL,c.WRZ,c.GRZ,c.OBHTZ,c.OBHTZTM,(a.Z-c.WRZ) OWRZ,(a.Z-c.GRZ) OGRZ,(a.Z-c.OBHTZ) OHTZ
from ST_RIVER_R a,ST_STBPRP_B b,ST_RVFCCH_B c
where a.STCD=b.STCD and a.STCD=c.STCD and a.TM between '2009-09-13 13:00:00' and '2009-09-14 13:00:00' and (a.STCD = '30301400' or a.STCD = '30301600' or a.STCD = '30301800' or a.STCD = '30301801' or a.STCD = '30301804') and -5.0<=OWRZ and OWRZ<0 order by a.STCD asc


报错为:“Invalid column name 'OWRZ' ",请指教
Qubook的主页 Qubook | 初学一级 | 园豆:0
提问于:2009-09-14 13:45
< >
分享
其他回答(1)
0

根据错误提示“OWRZ是无效的列名”,你看一下a.Z和c.WRZ这两列的字段类型是否匹配。

Kinglee | 园豆:3158 (老鸟四级) | 2009-09-14 14:01
嗯,字段类型是匹配的
支持(0) 反对(0) Qubook | 园豆:0 (初学一级) | 2009-09-14 14:08
0

楼上分析的没错;

你检查下这两相字段是否一致?从最后的where条件来看,都是double 或float?

另外,你可以把语句多写出几行,以便系统提示第几行出错

试下这个

 

select a.STCD,a.TM,a.Z,a.Q,a.XSA,a.XSAVV,a.XSMXV,a.FLWCHRCD,a.WPTN,a.MSQMT,a.MSAMT,a.MSVMT,
b.STNM,b.RVNM,b.STLC,b.BGFRYM,c.LDKEL,c.RDKEL,c.WRZ,c.GRZ,c.OBHTZ,
c.OBHTZTM,(a.Z
-c.WRZ) OWRZ,(a.Z-c.GRZ) OGRZ,(a.Z-c.OBHTZ) OHTZ
from ST_RIVER_R a,ST_STBPRP_B b,ST_RVFCCH_B c
where a.STCD=b.STCD and a.STCD=c.STCD and a.TM between '2009-09-13 13:00:00' and '2009-09-14 13:00:00'
and (a.STCD = '30301400' or a.STCD = '30301600' or a.STCD = '30301800' or a.STCD = '30301801' or a.STCD = '30301804')
and OWRZ>=-5 and OWRZ<0 order by a.STCD asc

 

MSSQL中只能如此,否则也报错"列名 '***' 无效。"

select * from 
(
select a.STCD,a.TM,a.Z,a.Q,a.XSA,a.XSAVV,a.XSMXV,a.FLWCHRCD,a.WPTN,a.MSQMT,a.MSAMT,a.MSVMT, b.STNM,b.RVNM,b.STLC,b.BGFRYM,c.LDKEL,c.RDKEL,c.WRZ,c.GRZ,c.OBHTZ,c.OBHTZTM,(a.Z-c.WRZ) OWRZ,(a.Z-c.GRZ) OGRZ,(a.Z-c.OBHTZ) OHTZ
from ST_RIVER_R a,ST_STBPRP_B b,ST_RVFCCH_B c
where a.STCD=b.STCD and a.STCD=c.STCD and a.TM between '2009-09-13 13:00:00' and '2009-09-14 13:00:00' and (a.STCD = '30301400' or a.STCD = '30301600' or a.STCD = '30301800' or a.STCD = '30301801' or a.STCD = '30301804') order by a.STCD asc
)
where -5.0<=OWRZ and OWRZ<0

 

可能还是你原来的语句放在where内层效率高。但是你的or条件似乎可以用in更好些。

你试着跟踪一下语句看看

邀月 | 园豆:25375 (高人七级) | 2009-09-14 14:17
出错的地方是-5.0<=OWRZ and OWRZ<0,这里如果用(a.Z-c.WRZ)替换就没有问题了,字段类型都是N(7,3)
支持(0) 反对(0) Qubook | 园豆:0 (初学一级) | 2009-09-14 14:26
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册