Oracle 我们如何将多行转换成单行
我的预期产出是:Oracle 我们如何将多行转换成单行,oracle,oracle11g,Oracle,Oracle11g,我的预期产出是: ACCOUNT_NUM IMSI PREVIOUS_MONTH CURRENT_MONTH ACC000142 310640100000003 10/8/2015 5:18:29 AM ACC000142 310640100000003 11/3/2015 11:25:33 PM ACC000142 310640100000003
ACCOUNT_NUM IMSI PREVIOUS_MONTH CURRENT_MONTH
ACC000142 310640100000003 10/8/2015 5:18:29 AM
ACC000142 310640100000003 11/3/2015 11:25:33 PM
ACC000142 310640100000003 11/3/2015 5:18:29 AM
ACC000142 310640100000003 10/8/2015 11:25:33 PM
看起来你想做的是
ACCOUNT_NUM IMSI PREVIOUS_MONTH CURRENT_MONTH
ACC000142 310640100000003 10/8/2015 5:18:29 AM 11/3/2015 11:25:33 PM
祝你好运。看来你想做的事情
ACCOUNT_NUM IMSI PREVIOUS_MONTH CURRENT_MONTH
ACC000142 310640100000003 10/8/2015 5:18:29 AM 11/3/2015 11:25:33 PM
祝你好运。有人能帮我吗……有人能帮我吗。。。
with ces as (select account_num,
imsi,
u.previous_month,
u.current_month
ls.status
from (select account_num,
imsi,
case
when usage_date < add_months(to_date('20151110','yyyymmdd'),-1) then usage_date
else null
end previous_month,
case
when usage_date >= add_months(to_date('20151110','yyyymmdd'),-1) then usage_date
else null
end current_month
from genevabatchuser.loadusagedata
where event_source = 'NUMEREXROMHYB' and
account_num = 'ACC000142' and
imsi in ('310640100000003','310640100000004','310640100000338','310640100000331'))u
full outer join GENEVABATCHUSER.TMOLOADIMSILIST ls
using (account_num, imsi))
select ACCOUNT_NUM,
IMSI,
MIN(PREVIOUS_MONTH) AS PREVIOUS_MONTH,
MAX(CURRENT_MONTH) AS CURRENT_MONTH
from ces
where imsi in ('310640100000003','310640100000004','310640100000338','310640100000331')
GROUP BY ACCOUNT_NUM, IMSI;