Home » SQL & PL/SQL » SQL & PL/SQL » MAtrix Query ( Complex ) (9i)
MAtrix Query ( Complex ) [message #312291] 
Tue, 08 April 2008 07:51 
jhedshi
Messages: 13 Registered: February 2008

Junior Member 


Hi,
there is a query which we have written :
select A.po,
MAX(CASE WHEN A.N = 1 THEN A.B_nm ELSE NULL END) AS N1,
MAX(CASE WHEN A.N = 1 THEN A.Per ELSE NULL END) AS P1,
MAX(CASE WHEN A.N = 2 THEN A.B_nm ELSE NULL END) AS N2,
MAX(CASE WHEN A.N = 2 THEN A.Per ELSE NULL END) AS P2,
MAX(CASE WHEN A.N = 3 THEN A.B_nm ELSE NULL END) AS N3,
MAX(CASE WHEN A.N = 3 THEN A.Per ELSE NULL END) AS P3,
Now when there is only 1 N1 then output is :
A.PO N1
 
1 F
AND if there are 3 N1's output is for 3 N1's.
We have included only 3 N3's in the query. If there is data for 5 i.e. A.N = 5 then i will have to included it in the query. Is there any way to generalize the query so that if there is
CASE WHEN A.N = 10 , it will return data for 10 automatically ?
Please help. kindly ask if more clarifications needed ..
Regards..





Goto Forum:
Current Time: Sun Jan 22 12:45:42 CST 2017
Total time taken to generate the page: 0.09486 seconds
