sql - SELECT only those columns, where values are NOT NULL -
I have a selection statement (using the function), which gives 60 columns and approximately 10000 lines, some of these columns There are only zero values - I want to exclude them from selection. Is there any way to do this?
The query is a bit complex, including the tabfunction function, but the results are very good:
------ - + ------- + -------- + --------- + --------- + ID Column1 | Column2. ... | Column 60 | -------- + ------- + -------- + --------- + --------- + 1 | 1 | Faucet 52.5 | 15 | ... | ... | ... | ... | ... | 10000 | 2 | Faucet 87.5 | 3 | -------- + ------- + -------- + --------- + --------- +
In this situation I do not want to select column 2.
is the query:
select to dma.ct_fafajkod_pont ('select one, .pont, a.faj, a.tom (select f.ppont_azon pont, fl .mezonev faj, case WHEN f.tom08 :: integer = 1 then 2.5 WHEN f.tom08 :: integer = 2 again 12.5 WHEN f.tom08 :: integer = 3 then 35 WHEN tom08 :: integer = 4 then 75 and 0 ed + Case WHEN f.tom920 :: integer = 1 then 2.5 WHEN f.tom920 :: integer = 2 again 12.5 WHEN f.tom920 :: integer = 3 then 35 WHEN tom920 :: integer = 4 then 75 and 0 end + case WHEN F.tom2135 :: integer = 1 then 2.5 WHEN f.tom2135 :: integer = 2 again 12.5 WHEN f.tom2135 :: integer = 3 35 WHEN tom2135 :: integer = 4 then 75 and 0 end + case WHEN f.tom3650: : Integer = 1 then 2.5 WHEN f.tom3650 :: integer = 2 again 12.5 WHEN f.tom3650 :: integer = 3 then 35 WHEN tom3650 :: whole = 4 then 75 and 0 nd + case WHEN f.tom51 :: integer = 1 then 2.5 WHEN f.tom51 :: integer = 2 again 12.5 WHEN f.tom51 :: integer = 3 then 35 WHEN tom51 :: integer = 4 Then select specific fl.mezonev from Field and F.Fajaj, field.fafajlista fl where f.fajnev = fl.fafaj_kulcs 1,2 'by an order,' then field. Fifthist list order from 1 ');
You can specify the column to choose from, such as:
selection ID, table 1 from column;
Or you can do this as a suggestion and you can select columns directly from the schema and exclude the ones you do not want to:
< Code> SELECT 'SELECT' | | WHERE table_name = 'officepark' and c.column_name ('office perkid', 'contractor')), ', as' info_schema.column' from C.column_name, 'Array_to_string (ARRE_to_string (' SELECT 'O' || '.' ') || || After reading AsclistMT
Edit: like 'o as office', I know that if you want to do it dynamically, then this answer Will not help / P>
Comments
Post a Comment