现在在做一个oracle数据库向DB2数据库的迁移工作,遇到问题不知道怎么解决,DB2的大侠帮帮忙啊
sql 如下
[code=SQL]
select
session_id,
substr(LOGIN_TIME,1,14)|| '00 ' TIME_ID,
LOGIN_TIME,
(select max(LOGIN_TIME) from foc_session where USER_ID=t.USER_ID and LOGIN_TIME <t.LOGIN_TIME) LAST_LOGIN_TIME,
0,
DISTRICT_ID,
AGE_ID,
JOB_ID,
ASSETS_ID,
VISIT_FLAG,
SEX_ID,
coalesce(SCREEN_ID, '99 '),
ORG_ID,
to_char(to_date(substr(login_time,1,10), 'YYYY-MM-DD '), 'D ')-1 WEEK_ID ,
(select sum(REMAIN_TIME) from FOC_TRAN_MKT_ALL_ACTION where session_id=t.session_id) REMAIN_TIME,
coalesce(BROWSER_ID, '99 '),
coalesce(OS_ID, '99 '),
EDUCATE_ID,
USER_ID CUST_ID,
sum(COUNTFOCID) COUNT_PV,
sum((select sum(case SESSION_FLOG when '2 ' then 1 else 0 end) QUIT_FLAG from FOC_TRAN_MKT_ALL_ACTION where session_id=t.session_id)) COUNT_OUTOF
from FOC_TRAN_MKT_ALL_SESSION t
group by
session_id,
LOGIN_TIME,
DISTRICT_ID,
AGE_ID,
JOB_ID,
ASSETS_ID,
VISIT_FLAG,
SEX_ID,
SCREEN_ID,
ORG_ID,
logout_time,
BROWSER_ID,
OS_ID,
EDUCATE_ID,
USER_ID;
[/code]
报错如下
SQL0112N The operand of the column function "SYSIBM.SUM " includes a column function, a scalar fullselect, or a subquery. SQLSTATE=42607
我知道问题出在
[code=SQL]
sum((select sum(case SESSION_FLOG when '2 ' then 1 else 0 end) QUIT_FLAG from FOC_TRAN_MKT_ALL_ACTION where session_id=t.session_id)) COUNT_OUTOF
[/code]
这一行,但不知道怎么解决,求高手
------解决方案--------------------------------------------------------
没有看到记录,试试
...
sum(case SESSION_FLOG when '2 ' then 1 else 0 end)
from FOC_TRAN_MKT_ALL_SESSION t inner join FOC_TRAN_MKT_ALL_ACTION c on c.session_id=t.session_id
...