#将lwproject的Currency的总数除以projectid的个数 将结果赋值给lwcustomer的field20表提示ORA-00936 missing expression 错误.....
update lwcustomer a set a.field20=select sum(p.currency) from lwproject p where p.status='4'/select count(s.projectid) from lwproject s ,a.oler='-1' where a.customername='AIM'
update lwcustomer a set a.field20=select sum(p.currency) from lwproject p where p.status='4'/select count(s.projectid) from lwproject s ,a.oler='-1' where a.customername='AIM'
解决方案 »
- Tomcat4.1连接数据库(Oracle)的问题
- sqlplus / as sysdba 的问题
- 不能登录数据库的问题
- 老是出现 ORA-12560 错误
- oracle 10g的ip地址修改以后,http://localhost:1158/em不能访问的问题
- 这样的SQL语句要怎么写?
- 这个功能是否能够用触发器实现?请高手看看,需求比较简单,但是我不知道该怎么写。
- 关于多人同时向数据库插入一条记录的问题
- 请问怎样在oracle中得出系统日期.这里只要日期比如2号不要年不要月分
- win2000专业版下,安装oracle9i在安装到87%时,不进行了,没死机,没错误提示!!
- oracle时间检索问题
- vc6开发的程序 64位的oracle10.2客户端 连接 64位AIX5.3机器上的oracle10.2的数据库服务器 失败
我的意思是:把某个客户做的项目全部的金额 除以项目的个数 放在lwcustomer客户表中的一个字段
(其他好多查询条件没加上 这是简写的,怕别人看着烦)
报错?
你看看
p.currency 这个字段是字符型的?如果是的话p.currency要改成to_number(p.currency)
count(case oler when '-1' then p.projectid end) from lwproject p)
where a.customername='AIM'
还是报这个inconsistent datatypes:expected number got char错误
set a.field20=
(select sum(case p.status when '4' then to_number(p.currency) end)
/
count(case oler when '-1' then p.projectid end) from wproject p)
where a.customername='AIM'先判断分母是否为零,最后将分子,分母赋值给临时变量:临时变量1=(select sum(case p.status when '4' then to_number(p.currency) end) ;临时变量2=count(case oler when '-1' then p.projectid end) from wproject p)
where a.customername='AIM'
最后:update lwcustomer a
set a.field20= 临时变量1 / 临时变量2