Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: A tricky SQL statement

Re: A tricky SQL statement

From: <Solomon.Yakobson_at_entex.com>
Date: 1997/01/30
Message-ID: <854635562.30734@dejanews.com>#1/1

Yes, ORACLE does not provide any means to pivot table as it was mentioned by Dan Rippel. Although if you know all the values in MIDENT column you are interested in, solution is much eazier with much better performance than one suggested by Chris Halioris.

  SELECT Sident,

          DECODE(Mident,'B1',M00,NULL) B1,
          DECODE(Mident,'B2',M00,NULL) B2,
          DECODE(Mident,'L1',M00,NULL) L1,
          DECODE(Mident,'RF',M00,NULL) RF
    FROM Your_Table;

Solomon.Yakobson_at_entex.com

In article <32EF4DE3.7D54_at_vegdir.vegvesen.no>,   Anders Hattestad <anders.hattestad_at_vegdir.vegvesen.no> wrote:
>
> I have a table that looks like this:
>
> sident mident dato m00
> M201 B1 07-16-95 2983
> M201 B2 07-16-95 2996
> M201 L1 07-16-95 2956
> M201 RF 07-16-95 3
> M201 VH 07-16-95 1
> M201 VR 07-16-95 33
> M251 B1 11-22-93 2555
> M251 L1 11-22-93 2535
> M251 RF 11-22-93 88
> M251 VH 11-22-93 6
> M251 VR 11-22-93 7
> M253 B1 11-30-93 2658
>
> And I would like to extract it on this form:
>
> Sident B1 B2 L1 RF
> M201 2983 2996 2956 3
> M251 2535 88
> M253 2658
>
> Have any of you a solution on how this sql statement should look like?
>
> Thanks in advances
> Anders

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet
Received on Thu Jan 30 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US