sql - SELECT only those columns, where values are NOT NULL -



sql - SELECT only those columns, where values are NOT NULL -

i have select statment (using function), returns 60 columns , 10000 rows. of these columns contain null values - want exclude them selection. there way this?

the query bit complicated, including tablfunc function, results nice:

--------+-------+--------+---------+---------+ id |column1| column2| ... |column60 | --------+-------+--------+---------+---------+ 1 | 1 | null | 52.5 | 15 | ... | ... | ... | ... | ... | 10000 | 2 | null | 87.5 | 3 | --------+-------+--------+---------+---------+

in case don't want select column2.

the query is:

select * dma.ct_fafajkod_pont ('select a.pont, a.faj, a.tom (select f.ppont_azon pont, fl.mezonev faj, case when f.tom08::integer=1 2.5 when f.tom08::integer=2 12.5 when f.tom08::integer=3 35 when tom08::integer=4 75 else 0 end + case when f.tom920::integer=1 2.5 when f.tom920::integer=2 12.5 when f.tom920::integer=3 35 when tom920::integer=4 75 else 0 end + case when f.tom2135::integer=1 2.5 when f.tom2135::integer=2 12.5 when f.tom2135::integer=3 35 when tom2135::integer=4 75 else 0 end + case when f.tom3650::integer=1 2.5 when f.tom3650::integer=2 12.5 when f.tom3650::integer=3 35 when tom3650::integer=4 75 else 0 end + case when f.tom51::integer=1 2.5 when f.tom51::integer=2 12.5 when f.tom51::integer=3 35 when tom51::integer=4 75 else 0 end tom field.fafaj f, field.fafajlista fl f.fajnev=fl.fafaj_kulcs ) order 1,2', 'select distinct fl.mezonev field.fafajlista fl order 1');

you explicitly specify columns select, like:

select id, column1 table;

or suggested here , select columns straight schema , exclude ones don't want:

select 'select ' || array_to_string(array(select 'o' || '.' || c.column_name information_schema.columns c table_name = 'officepark' , c.column_name not in('officeparkid', 'contractor') ), ',') || ' officepark o' sqlstmt

edit: after reading guildsbounty's comment above, realise reply isn't going help if want dynamically.

sql postgresql select

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -