我是想既显示有关数字段,又要统计出有关字段的记录,但不分组:例如:
SELECT SUBSTR(xh,1,5) as bmd ,COUNT(*) as rs FROM bmk0651 WHERE tot1>=600
上面的命令,通不过,出现 group by 子句缺少或无效。一定要加 group by bmd
我是想既显示有关数字段,又要统计出有关字段的记录,但不分组:例如:
SELECT SUBSTR(xh,1,5) as bmd ,COUNT(*) as rs FROM bmk0651 WHERE tot1>=600
上面的命令,通不过,出现 group by 子句缺少或无效。一定要加 group by bmd
那就只能采用子查询分别查出,再强制联接的办法去做:
SELECT BMD,RS ; FROM (SELECT SUBSTR(T1.XH,1,5) BMD ; FROM BMK0651 WHERE TOT1>=600) T1, ; (SELECT COUNT(*) RS ; FROM BMK0651 WHERE TOT1>=600) T2
那就只能采用子查询分别查出,再强制联接的办法去做:
SELECT BMD,RS ; FROM (SELECT SUBSTR(T1.XH,1,5) BMD ; FROM BMK0651 WHERE TOT1>=600) T1, ; (SELECT COUNT(*) RS ; FROM BMK0651 WHERE TOT1>=600) T2