Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> DECODE column renaming question

DECODE column renaming question

From: Eric Bycer <ebycer_at_mediaone.net>
Date: Sat, 18 Nov 2000 20:53:20 GMT
Message-ID: <B63C56ED.11BF%ebycer@mediaone.net>

I have a quick decode question.

Is there a way to name the new column after a variable in the table? Say I have to generate a histogram aging table every month and want to pull the month names out of my data table.

ie

table data_table(

   t_heading varchar2(10),

   item         varchar2(15),
   ddate        date,
   m_name       varchar2(6)

);

select t_heading,

   SUM(DECODE(ddate, v_date, 1, 0) m_name from data_table
group by t_heading, m_name;

So that I get an output table like:

t_heading JAN-00 FEB-00 MAR-00....OCT-00 NOV-00

Open        4       10      2           18         20
Closed      10      5       0            0         12

I would think that there would be a way to do this other than hard coding everything in.

Any help would be appreciated.

Thanks,
Eric Bycer Received on Sat Nov 18 2000 - 14:53:20 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US