Re: a cross tab??

From: Totti <>
Date: Thu, 3 Jan 2008 07:35:41 -0800 (PST)
Message-ID: <>

well, to do this, i am trying to use two functions, but as i understood from the site Mr. Morgan sent me (thank him very much), the crosstabulation must be done from one table; this is not the case with me.the first two columns are generated so :

SELECT TO_CHAR(Pmt_date,'mm') MONTH ,TO_CHAR(Pmt_date,'YYYY') YEAR from purpmt
group by TO_CHAR(Pmt_date,'mm'),TO_CHAR(Pmt_date,'YYYY') order by TO_CHAR(Pmt_date,'YYYY')

and the rest like so:

select  decode(to_char(Prod_Code),'SP-20.2', qty) as frstProd,
decode(to_char(Prod_Code),'SP-20.1', qty ) as scndProd,
decode(to_char(Prod_Code),'SP-20.6', qty ) as thirdProd
from purch

now how can i relate those two functions? to get the result in the upper message and also i want to fill the gaps generated by the second func. by '0', but i am not sure how to use the NVL to do so.

Thanks you all Received on Thu Jan 03 2008 - 09:35:41 CST

Original text of this message