hgdb 實現Oracle pivo函式(APP)

2021-09-26 13:46:09 字數 1699 閱讀 4615

目錄

環境文件用途

詳細資訊

環境系統平台:microsoft windows (64-bit) 10

版本:4.3.2

文件用途

瀚高資料庫實現oracle中的多行轉列

詳細資訊

with temp as(

select '四川省' nation ,'成都市' city,'第一' ranking from dual union all

select '四川省' nation ,'綿陽市' city,'第二' ranking from dual union all

select '四川省' nation ,'德陽市' city,'第三' ranking from dual union all

select '四川省' nation ,'宜賓市' city,'第四' ranking from dual union all

select '湖北省' nation ,'武漢市' city,'第一' ranking from dual union all

select '湖北省' nation ,'宜昌市' city,'第二' ranking from dual union all

select '湖北省' nation ,'襄陽市' city,'第三' ranking from dual

select * from (select nation,city,ranking from temp)pivot (max(city) for ranking in ('第一' as 第一,'第二' as 第二,'第三' as 第三,'第四' as 第四));

with temp as(

select '四川省' nation ,'成都市' city,'第一' ranking from dual union all

select '四川省' nation ,'綿陽市' city,'第二' ranking from dual union all

select '四川省' nation ,'德陽市' city,'第三' ranking from dual union all

select '四川省' nation ,'宜賓市' city,'第四' ranking from dual union all

select '湖北省' nation ,'武漢市' city,'第一' ranking from dual union all

select '湖北省' nation ,'宜昌市' city,'第二' ranking from dual union all

select '湖北省' nation ,'襄陽市' city,'第三' ranking from dual

select nation,

max(decode(ranking, '第一'::varchar, city, ''::varchar)) as 第一,

max(decode(ranking, '第二'::varchar, city, ''::varchar)) as 第二,

max(decode(ranking, '第三'::varchar, city, ''::varchar)) as 第三,

max(decode(ranking, '第四'::varchar, city, ''::varchar)) as 第四

from temp group by nation order by nation desc ;

更多詳細資訊請登入【瀚高技術支援平台】檢視

hgdb 時區調整 APP

目錄 環境文件用途 詳細資訊 環境系統平台 microsoft windows 64 bit 10 版本 4.3.2 文件用途 有時候作業系統的時間與pg的時間不一致,這往往使兩者時區不一致造成的 詳細資訊 postgres rudy 01 data date thu nov 19 09 39 58...

HGDB兩表間資料複製

目錄 文件用途 詳細資訊 文件用途 本文件提供select into和insert into select兩種表複製語句的使用方法及示例。詳細資訊 在hgdb中的select into和insert into select兩種表複製語句都可以用來複製表與表之間的資料。1.insert into fr...

HGDB批量執行psql命令的指令碼

存放指令碼的伺服器需要安裝hgdb客戶端 root localhost groupadd g 5866 highgo root localhost useradd u 5866 g highgo highgo echo highgo passwd f stdin highgo root localh...