不使用crosstab實現PostgreSQL的行轉列應用,crosstabpostgresql

來源:互聯網
上載者:User

不使用crosstab實現PostgreSQL的行轉列應用,crosstabpostgresql

表結構及資料


select logdatetime,sum(login) as login,sum(logo) as logo

from(
SELECT date(logdatetime) AS "logdatetime", case logfrom when 'login' then COUNT(id) else 0 end AS "login",
case logfrom when 'logo' then COUNT(id) else 0 end AS "logo"
FROM "log" WHERE date(logdatetime) >= '2014-11-04' AND date(logdatetime) <= '2014-11-05' GROUP BY "logdatetime", "logfrom"
) T
GROUP BY "logdatetime"

ORDER BY "logdatetime" ASC

執行結果



你是怎把MySQL成功轉為PostgreSQL的,可以不可以告訴我,我有一個MySQL的網站,想把它改成postgreSQL

如果表結構在mysql和postgresql的結構差別不大,那麼相互遷移是比較簡單的。
可以通過用shell指令碼來處理能很好的實現。
第一:mysql 匯出文字檔。
第二:shell處理文字檔的格式,使之適合postgresql匯入格式,產生至目標文字檔。
第三:在postgresql中執行目標文字檔即可。
 
PB 資料視窗crosstab definition 新增列時怎不使原有資料視窗中的排列順序及效果被打亂

我還暫時找不到方法解決。每次增加列,都是重做。其他改動應該可以在 edit soure 中完成。
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.