Re: SQL: can you select certain cols...???

From: <febbo_at_madnix.uucp>
Date: 1995/04/06
Message-ID: <1995Apr6.045435.17221_at_madnix.uucp>#1/1


: I want to retrieve the values 1.4, 5.3, 4.5, 2.3, and 3.1 (including the column : names so that I know where the values came from).

I think I have this one for you Steve .....        
        
   consider TABLE MY_TAB  made up of NUMBERS      

         elem1   elem2    elem3    elem4    ...........
         -----   ------   ------  ------     
values    1.1     0        1.2     0        ...........
values    0      1.3        0     1.4       ...........
values    1.5    1.6       1.7     0        ...........


SET HEADING OFF

SELECT DECODE (ELEM1,0,'','ELEM1='||TO_CHAR(ELEM1),

(ELEM2,0,'','ELEM2='||TO_CHAR(ELEM2),
(ELEM3,0,'','ELEM3='||TO_CHAR(ELEM3),
(ELEM4,0,'','ELEM4='||TO_CHAR(ELEM4)
FROM MY_TAB; This will replace zero elements with nothing and will replace non-zero elements with a colume-id followed by value.

output:

ELEM1=1.1
ELEM3=1.2
ELEM2=1.3
ELEM4=1.4
ELEM1=1.5
ELEM2=1.6
ELEM3=1.7

You can replace the 'elem?=' lables with anything or format the
              values across the page, as you wish.
                            

Best regards ....James Febbo febbo_at_njackn.com Received on Thu Apr 06 1995 - 00:00:00 CEST

Original text of this message