以下是引用taifu945在2013-6-6 22:55:33的发言:
先不去搞你这句命令的含义了,单就语法本身,应该是:
SELECT SUM(dj*shl2) FROM (SELECT dj, SUM(shuliang) AS shl2 FROM wp GROUP BY spbh,spmc HAVING shl2>0) T1
1、在FROM子句中,必须要为子查询起个临时的表名;
2、Shl2这个变量代表了表达式“SUM(shuliang)”,所以不能放在WHERE子句中,只能放在HAVING子句中。WHERE子句中不允许使用聚集函数。
以上2点仅是你写出来的代码有问题的地方。另外,由于版本不同,你的GROUP BY子句可能会被VFP6.0接受,但在9.0中也不能通过,必须要加上dj。因为VFP9.0的SQL命令移植了大型数据库系统的SQL命令,这种命令规定了:输出项中若包含聚集函数,则其它不含聚集函数的输出项全部要作为分组字段。
SELECT SUM(dj*shl2) FROM (SELECT spbh,dj, SUM(shuliang) AS shl2 FROM liushuiw GROUP BY spmc HAVING shl2>0 into table T1)
SELECT SUM(dj*shl2) FROM (SELECT spbh,dj, SUM(shuliang) AS shl2 FROM liushuiw GROUP BY spmc HAVING shl2>0) into table T1
SELECT SUM(dj*shl2) FROM (SELECT spbh,dj, SUM(shuliang) AS shl2 FROM liushuiw GROUP BY spmc HAVING shl2>0) T1
以上诸条语句在vf6下均提示语法错误
比较闹心的是
如何才能让它提示哪里出错了呢
就笼统的一句语法错误