p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

sql_language thread: Results to Columns Help


Message #1 by "Lee Cullinan" <lee.cullinan@p...> on Tue, 12 Mar 2002 11:37:11
DURRRRR, MY MISTAKE, I NEED TO REPLACE (PERIOD, '1',1)) WITH
(PERIOD, '1',INVOICES))  WORKS A TREAT !!!!













> I require results from a query to be inserted into new columns. I have 
> used the following to achieve the columns and results,
> 
> SELECT 
> PROD_CODE,
> YEAR,
> SUM(DECODE (PERIOD, '1',1)) PRINV_1,
> SUM(DECODE (PERIOD, '2',1)) PRPINV_2,
> SUM(DECODE (PERIOD, '3',1)) PRPINV_3,
> SUM(DECODE (PERIOD, '4',1)) PRPINV_4,
> SUM(DECODE (PERIOD, '5',1)) PRPINV_5,
> SUM(DECODE (PERIOD, '6',1)) PRPINV_6,
> SUM(DECODE (PERIOD, '7',1)) PRPINV_7,
> SUM(DECODE (PERIOD, '8',1)) PRPINV_8,
> SUM(DECODE (PERIOD, '9',1)) PRPINV_9,
> SUM(DECODE (PERIOD, '10',1)) PRPINV_10,
> SUM(DECODE (PERIOD, '11',1)) PRPINV_11,
> SUM(DECODE (PERIOD, '12',1)) PRPINV_12,
> SUM(DECODE (PERIOD, '131',1)) PRPINV_13 
> FROM 
> INVOICE_TABLE 
> GROUP BY 
> PROD_CODE,
> YEAR
> ORDER BY 
> PROD_CODE 
> 
> I cannot seem to get the results as a SUM it only counts, for instance 
in 
> one of the new fields there should be the result 11 after calculation 
> however it is only returning 1 as a count result.
> 
> Any Ideas would be appreciated.

  Return to Index