select t2.main_ditch, t3.ditch_name, count(*), round(sum(c.order_money))/100 as amount,t3.id
from t_main_ditch t3 right join t_cas_userst t2 on t2.main_ditch=t3.ditch_no
right join t_sub_ditch ts on ts.ditch_no=t2.sub_ditch
right join t_cas_trade t on t.cas_id=t2.id right join t_combo c on t.combo_id=c.id
group by t2.main_ditch,t3.ditch_name,t3.id, ts.main_ditch_id,t3.ditch_no
having ts.main_ditch_id=t3.id and t2.main_ditch=t3.ditch_no 我要求 sum( count(*)) ,sum( amount) 如何去写?
from t_main_ditch t3 right join t_cas_userst t2 on t2.main_ditch=t3.ditch_no
right join t_sub_ditch ts on ts.ditch_no=t2.sub_ditch
right join t_cas_trade t on t.cas_id=t2.id right join t_combo c on t.combo_id=c.id
group by t2.main_ditch,t3.ditch_name,t3.id, ts.main_ditch_id,t3.ditch_no
having ts.main_ditch_id=t3.id and t2.main_ditch=t3.ditch_no 我要求 sum( count(*)) ,sum( amount) 如何去写?
解决方案 »
- 请教Oracle9i中单列索引和组合索引问题
- 关于日期比较问题(高分赠送)
- 存储过程里如何知道update后是否成功更新了数据,更新了多少条?
- CLOB类型转换?如何取代“Top 1”?急求解决方法!非常感谢!
- 江湖救急:帮我看看那里错了
- sql语句的效率分析
- 我遇到了toad的启动问题,toad一闪就没了
- 菜鸟 利用SQL*Loader将 *.text数据导出到 Oracle 数据库中??
- 如何记录单据改变的记录步骤?
- 没有oracle服务端复制文件的权限,Linux的oracle客户端如何获取并使用sqlldr?
- 两年java经验,转DBA 大家提点意见(批评也好、鼓励也好一律接受)
- windows 64位expdp导出,windows 32位impdp 导入提示异常
-- 既然已经有 count(*) 了,为什么还要用 sum()函数去嵌套呢? 你不觉得是画蛇添足么?
select deptno, sum(count(empno)) from emp group by deptno
*
第 1 行出现错误:
ORA-00937: 不是单组分组函数
scott@TBWORA> select deptno, count(empno) from emp group by deptno; DEPTNO COUNT(EMPNO)
---------- ------------
30 6
20 5
10 3scott@TBWORA> select deptno, sum(count(*)) from emp group by deptno;
select deptno, sum(count(*)) from emp group by deptno
*
第 1 行出现错误:
ORA-00937: 不是单组分组函数
a b c d e
1111 4510 1 14 2
4551 1710 3 42 2
1534 5310 4 65 2
我要算 这个 c ,d 的总合 在 select t2.main_ditch as a1, t3.ditch_name as a2 ,
count(*) as a3, round(sum(c.order_money))/100 as a4,t3.id as a5
from t_main_ditch t3 right join t_cas_userst t2 on t2.main_ditch=t3.ditch_no
right join t_sub_ditch ts on ts.ditch_no=t2.sub_ditch
right join t_cas_trade t on t.cas_id=t2.id right join t_combo c on t.combo_id=c.id
group by t2.main_ditch,t3.ditch_name,t3.id, ts.main_ditch_id,t3.ditch_no
having ts.main_ditch_id=t3.id and t2.main_ditch=t3.ditch_no
这个基础上 如何解得?
我再外面嵌套的话~这个速度会不会NNNNNN慢的?