これは私のSQLクエリです。これらの結果を垂直方向に表示します。私はまた、私は\x\g\x
を使用してトグルモードをオンにすることがわかった私のためにGoogleを検索したが、私はその構文をどこに置くべきかわからない。私は、これはあなたの条件に一致することを願ってい私のクエリ結果をpostgresqlに垂直に表示するには?
select
round(
100.00 *
(sum(case when "WELL_AGE" <= '5' AND "CONC_ARSC" <= '10' then 1 else 0 end))/(sum(case when "WELL_AGE" <= '5' then 1 else 0 end)),1) conc_arscbelow5_wellageGrp,
round(
100.00 *
(sum(case when "WELL_AGE" >= '6' AND "WELL_AGE" <= '10' AND "CONC_ARSC" <= '10' then 1 else 0 end))/(sum(case when "WELL_AGE" >= '6' AND "WELL_AGE" <= '10' then 1 else 0 end)),1) conc_arscbet6_10wellageGrp,
round(
100.00 *
(sum(case when "WELL_AGE" >= '11' AND "WELL_AGE" <= '15' AND "CONC_ARSC" <= '10' then 1 else 0 end))/(sum(case when "WELL_AGE" >= '11' AND "WELL_AGE" <= '15' then 1 else 0 end)),1) conc_arscbet11_15_wellageGrp,
round(
100.00 *
(sum(case when "WELL_AGE" >= '16' AND "WELL_AGE" <= '30' AND "CONC_ARSC" <= '10' then 1 else 0 end))/(sum(case when "WELL_AGE" >= '16' AND "WELL_AGE" <= '30' then 1 else 0 end)),1) conc_arscbet16_30wellageGrp,
round(
100.00 *
(sum(case when "WELL_AGE" >= '31' AND "WELL_AGE" <= '50' AND "CONC_ARSC" <= '10' then 1 else 0 end))/(sum(case when "WELL_AGE" >= '31' AND "WELL_AGE" <= '50' then 1 else 0 end)),1) conc_arscbet31_50wellageGrp,
round(
100.00 *
(sum(case when "WELL_AGE" > '50' AND "CONC_ARSC" <= '10' then 1 else 0 end))/(sum(case when "WELL_AGE" > '50' then 1 else 0 end)),1)conc_arscabove50_wellageGrp
from public."Arsenic_Test";
このhttp://stackoverflow.com/questions/23060256/postgres-transpose-rows-to-columns –
'\ x'コマンドはコマンドラインクライアント' psql'に対してのみ有効で、単純にSQLクエリの出力を "回転"します。 'psql'メタコマンド' \ x \ g \ x'はありません。 '\ g'は編集バッファから文を実行します。 –
私のニーズを達成するためには何が必要ですか? –