2017-02-07 1 views
0

私は、SELECTクエリを持っているし、私の列の型はテキストですが、その後、私は、クエリpostgresqlのselectクエリで列の合計を挿入する方法は?

select case 
    when fti.status!='not signed' then 1::integer 
    when ftrq.is_the_site_cleared = '1' then 1::integer 
    when ftrq.is_the_site_cleared = '0' then 0::integer 
    end as is_the_site_cleared from fti join ftrq on ftrq.fulcrum_parent_id = fti.fulcrum_id 
を使用して整数にそれを投げ入力

私はこのような列数を持ち、それらとして最後の値の合計を持っているしたいです列の下にsum(is_the_site_cleared)のように表示されます。どうすればこれを達成できますか?私は合計(テキスト)関数が存在しないと言うpostgresql 9.3を使用しています。助けてください!!!

答えて

1
select sum(is_the_site_cleared) from (select case 
     when fti.status!='not signed' then 1 
     when ftrq.is_the_site_cleared = '1' then 1 
     when ftrq.is_the_site_cleared = '0' then 0 
     end as is_the_site_cleared from fti join ftrq on 
     ftrq.fulcrum_parent_id = fti.fulcrum_id) res; 
関連する問題