*La consulta un poco modificada:*
SELECT
uploaddet_importcomp.indice,
case when historicotemp.activo ='N' then 'Beneficiario inactivo.' else null
end as motivo_res,
case when historicotemp.activo ='N' then 'I' else 'S' end as estado_res,
historicotemp.afitipocategoria categ,
historicotemp.clavebene
hola yo utilizo en pgadmin este sql como macro.
http://www.pgadmin.org/docs/1.8/macros.html
select
cols.table_catalog,cols.table_name,cols.column_name,pg_catalog.col_description(c2.oid,cols.ordinal_position::int)
from information_schema.columns cols
inner join pg_catalog.pg_class c on c.relname=