RE: Displaying rows as column headers help

From: Jackie Brock <J.Brock_at_cablelabs.com>
Date: Thu, 24 Jul 2008 15:00:06 -0600
Message-ID: <B1ED8A2E683E16479C92C3F4AE13677BE5CE6B@srvxchg3.cablelabs.com>


It's not dynamic, so you'd have to rewrite if a new one is added, but...  

select  code, col_id, species, fish_id,
decode(locus,'OMM1080v1',alleles,null),
decode(locus,'Oki10v1',alleles,null)...
 

-Jackie
 

Jackie D. Brock
Database Specialist - Systems Evaluation CableLabs(r)
858 Coal Creek Circle
Louisville, CO 80027
Email: j.brock_at_cablelabs.com <mailto:j.brock_at_cablelabs.com> 303-661-3347  


        From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of laura pena

	Sent: Thursday, July 24, 2008 2:38 PM
	To: oracle-l_at_freelists.org
	Subject: SQL: Displaying rows as column headers help
	
	

So I have the following requirement:  

CODE          COL_ID  SPECIES  FISH_ID   LOCUS     ALLELES
chintest           11       23220        1            Omm1080v1  252,268
chintest           11       23220        1            Oki10v1  183,241
chintest           11       23220        1            christian  252,268
chintest           11       23220        2            Omm1080v1  256,284
chintest           11       23220        2            Oke4v1     245,245
chintest           11       23220        2            Oki10v1  187,225


output to look like Locus should be shown columns wise with Alleles under the locus name:
CODE COLID SPE FISH_ID Omm1080v1 Oki10v1 christian Omm1080v1 Oke4v1

chintest      11       23220        1         252,268
chintest      11       23220        1                           183,241
chintest      11       23220        1
252,268
chintest      11       23220        2
256,284
chintest      11       23220        2
245,245
chintest      11       23220        2                            187,225

 

 

 

Any ideas how to (even a start would be good) write this query? Any help is as always appreciated.  

Thanks,

Lizz    

--

http://www.freelists.org/webpage/oracle-l Received on Thu Jul 24 2008 - 16:00:06 CDT

Original text of this message