Postgresql 选择两个带有大小写的列

Postgresql 选择两个带有大小写的列,postgresql,case,union,Postgresql,Case,Union,我想选择三列(id_produkt,313314),因此我尝试: select id_produkt, case when bp_stan_produkt.id_stan_produkt = 313 then 'TAK' else 'NIE' end as "313" from bp_stan_produkt where data_do is not null union select id_produkt, case when bp_stan_produkt.id_

我想选择三列(id_produkt,313314),因此我尝试:

select id_produkt, 
 case when bp_stan_produkt.id_stan_produkt = 313
 then 'TAK'
 else 'NIE' 
 end as "313"
 from bp_stan_produkt where data_do is not null

 union 

 select id_produkt, 
 case when bp_stan_produkt.id_stan_produkt = 314
 then 'TAK'
 else 'NIE'
 end as "314"
 from bp_stan_produkt where data_do is not null
但它只返回两列:id_produkt和313。 如何获得三个带别名的列?

试试下面的SQL代码

select id_produkt, 
case when id_stan_produkt = 313 then 'TAK' 
else 'NIE'
end  as "313",
case when id_stan_produkt = 314 then 'TAK' 
else 'NIE'
end  as "314"
 from bp_stan_produkt where data_do is null   
试试这个SQL代码

select id_produkt, 
case when id_stan_produkt = 313 then 'TAK' 
else 'NIE'
end  as "313",
case when id_stan_produkt = 314 then 'TAK' 
else 'NIE'
end  as "314"
 from bp_stan_produkt where data_do is null