0
我正在使用postgres RDBMS並希望在此上進行轉換。在postgres中創建一個樞軸點
如何在postgres中調整結果?
當我exe文件下面的查詢我得到這樣的結果
我發佈之前試過這個!
select * from
(
select count(tnx_id) as x,
case act_dt between 20140301 and 20140831 then '0-6 m'
when act_dt between 20130901 and 20140231 then '7-12 m'
when act_dt between 20130301 and 20130831 then '13-18 m'
else '18+'
end as act_bucket,
case when tnx_dt_int between 20140301 and 20140831 then '0-6 m'
when tnx_dt_int between 20130901 and 20140231 then '7-12 m'
when tnx_dt_int between 20130301 and 20130831 then '13-18 m'
else '18+'
end as tnx_bucket
from card
inner join tnx on card_id=tnx_cardh_id
group by act_bucket,tnx_bucket)
x1
pivot(x)
(
for tnx_bucket in([0-6 m],[7-12 m],[13-18 m],[18+])
)
so that i get like this
act_bucket
tnx_bucket 0-6 m 7-12 m 13-18 m 18+
0-6m < here filled with Count(tnx_id) >
7-12 m
13-18 m
18+
不客氣。請,如果這是正確的答案,請點擊複選標記! – jmvivo 2014-09-19 10:32:31