0
这是我的SQL查询,我想要这些结果垂直显示。我也搜索谷歌这一点,我发现通过使用\x\g\x
打开切换模式,但我不知道该把语法放在哪里。请帮助得到的输出是这样的:如何在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' metacommand'\ x \ g \ x'。 '\ g'将从编辑缓冲区运行语句。 –
那么,我需要做些什么来实现我的需求呢? –