标题:新手问题求助..
只看楼主
salo121
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-4-27
 问题点数:0 回复次数:5 
新手问题求助..

string r1,r2
date day,ld1,ld2
long xs
r1=em_1.text
r2=em_2.text
ld1=date('"+r1+"')
ld2=date('"+r2+"')

delete from day_xs;
commit;

declare p cursor for
select buyer_uid,sum(d_sales)
from st_buyer_sale
where RUN_DATE between :ld1 and :ld2;

open p;


fetch p into :day,:xs;
insert into day_xs values(:day,:xs);

close p;
commit;
dw_1.dataobject="q_new"
dw_1.settransobject(sqlca)
dw_1.retrieve()





保存时报错 提示:非单组组函数

求解....

搜索更多相关主题的帖子: between commit cursor insert values 
2006-05-09 17:19
ヤ順祺冄繎ヤ
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:3032
专家分:0
注 册:2005-11-9
得分:0 
以下是引用salo121在2006-5-9 17:19:00的发言:

string r1,r2
date day,ld1,ld2
long xs
r1=em_1.text
r2=em_2.text
ld1=date('"+r1+"')
ld2=date('"+r2+"')

delete from day_xs;
commit;

declare p cursor for
select buyer_uid,sum(d_sales)
from st_buyer_sale
where RUN_DATE between :ld1 and :ld2;

open p;


fetch p into :day,:xs;
insert into day_xs values(:day,:xs);

close p;
commit;
dw_1.dataobject="q_new"
dw_1.settransobject(sqlca)
dw_1.retrieve()





保存时报错 提示:非单组组函数

求解....

SQL有错吧!!!你這個sun是統計誰的總數呢?

2006-05-09 17:27
salo121
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-4-27
得分:0 

报错提示在where RUN_DATE between :ld1 and :ld2;
这一行

sum(d_sales)是计算st_buyer_sale 中d_sales这个字段在一段日期内的和

2006-05-09 17:50
ヤ順祺冄繎ヤ
Rank: 8Rank: 8
等 级:贵宾
威 望:42
帖 子:3032
专家分:0
注 册:2005-11-9
得分:0 

我估计你buyer_uid字段是多个值,而你sum(d_sales)的值只有一个,
所以你的SQL应该出错了.

2006-05-09 17:58
salo121
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2006-4-27
得分:0 

我加了group by 保存没问题了 但是运行的时候提示

database transaction information not available

call settrans or settransobject function....





string r1,r2
date day,ld1,ld2
long xs
r1=em_1.text
r2=em_2.text
ld1=date('"+r1+"')
ld2=date('"+r2+"')

delete from day_xs;
commit;

declare p cursor for
select buyer_uid,sum(d_sales)
from st_buyer_sale
where RUN_DATE between :ld1 and :ld2 group by buyer_uid;

open p;


fetch p into :day,:xs;
insert into day_xs values(:day,:xs);

close p;
commit;
dw_1.dataobject="q_new"
dw_1.settransobject(sqlca)
dw_1.retrieve() 郁闷...

2006-05-10 13:34
︷順⑦?zì繎
Rank: 1
等 级:新手上路
帖 子:255
专家分:0
注 册:2006-3-28
得分:0 
你没改正确,分组后用having
你只加了一个分组是没效果的.

2006-05-10 14:27



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-62878-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.082244 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved