Re: SQL: Displaying rows as column headers help

From: Nigel Thomas <nigel.cl.thomas_at_googlemail.com>
Date: Fri, 25 Jul 2008 07:50:21 +0100
Message-ID: <53258cd50807242350i2edc2560xc1c1c8fad1ccb84e@mail.gmail.com>


Laura

select code, col_id, species, fish_id

         , case when locus='Omm1080v1' then alleles else null end OMM180V1
         , case when locus='Oki10v1' then alleles else null end OKI10V1
... etc - one case expression per column required from whatever the table name is

(or oldtimers use DECODE instead of CASE)

Regards Nigel

2008/7/24 laura pena <lizzpenaorclgrp_at_yahoo.com>:

> 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 Fri Jul 25 2008 - 01:50:21 CDT

Original text of this message