此处不允许序号
【急】此处不允许序号?
insert into
archive_statistics
select
archive_statistics_seq.nextval,
'2014-11',
'11',
sum(first_open),
sum(curr_open),
sum(curr_debt),
sum(total_space),
sum(total_cost)
from
(
select
count(va_id) first_open,
0 curr_open,
0 curr_debt,
0 total_space,
0 total_cost
from
archive_log
where
val_opt_type = 0
and to_char(val_create_time, 'yyyy-mm-dd') = '2014-11-30'
union all
select
0 first_open,
decode(val_opt_after_status, 0, 1, 0) curr_open,
decode(val_opt_after_status, 1, 1, 0) curr_debt,
0 total_space,
0 total_cost
from
archive_log val,
(
select
va_id,
max(val_id) val_id
from
archive_log
where
to_char(val_create_time, 'yyyy-mm-dd') = '2014-11-30'
group by
va_id
) tab
where
val.val_id = tab.val_id
union all
select
0 first_open,
0 curr_open,
0 curr_debt,
decode(vacl_last_status, 0, vacl_all_space, 1, vacl_all_space, 2, vacl_all_space, 0) total_space,
decode(vacl_last_status, 0, vacl_total_cost, 1, vacl_total_cost, 0) total_cost
from
archive_cost_log
where
to_char(vacl_create_time, 'yyyy-mm-dd') = '2014-11-30'
)
一运行报ORA-02287错误:此处不允许序号,nextval之类的头一次接触,改半天也没弄成,具体怎么改呢,急啊,今天得改完。。。。。。100分不够再加!!谢了
------解决思路----------------------
序列不能用在分组查询当中
在外面再嵌套一层
就是说,把
select seq1.nextval,sum(a) from tab
改成
select seq1.nextval,sum_a from (
select sum(a) sum_a from tab)
的形式
------解决思路----------------------
都解决完了啊,呵呵,走鸟
insert into
archive_statistics
select
archive_statistics_seq.nextval,
'2014-11',
'11',
sum(first_open),
sum(curr_open),
sum(curr_debt),
sum(total_space),
sum(total_cost)
from
(
select
count(va_id) first_open,
0 curr_open,
0 curr_debt,
0 total_space,
0 total_cost
from
archive_log
where
val_opt_type = 0
and to_char(val_create_time, 'yyyy-mm-dd') = '2014-11-30'
union all
select
0 first_open,
decode(val_opt_after_status, 0, 1, 0) curr_open,
decode(val_opt_after_status, 1, 1, 0) curr_debt,
0 total_space,
0 total_cost
from
archive_log val,
(
select
va_id,
max(val_id) val_id
from
archive_log
where
to_char(val_create_time, 'yyyy-mm-dd') = '2014-11-30'
group by
va_id
) tab
where
val.val_id = tab.val_id
union all
select
0 first_open,
0 curr_open,
0 curr_debt,
decode(vacl_last_status, 0, vacl_all_space, 1, vacl_all_space, 2, vacl_all_space, 0) total_space,
decode(vacl_last_status, 0, vacl_total_cost, 1, vacl_total_cost, 0) total_cost
from
archive_cost_log
where
to_char(vacl_create_time, 'yyyy-mm-dd') = '2014-11-30'
)
一运行报ORA-02287错误:此处不允许序号,nextval之类的头一次接触,改半天也没弄成,具体怎么改呢,急啊,今天得改完。。。。。。100分不够再加!!谢了
------解决思路----------------------
序列不能用在分组查询当中
在外面再嵌套一层
就是说,把
select seq1.nextval,sum(a) from tab
改成
select seq1.nextval,sum_a from (
select sum(a) sum_a from tab)
的形式
------解决思路----------------------