Re: matrix transpose in SQL?

From: Aakash Bordia <a_bordia_at_hotmail.com>
Date: Mon, 30 Apr 2001 11:56:34 -0700
Message-ID: <9ckcal$n2u$1_at_stlnews.stl.ibm.com>


Makes sense. The kind of situation I was talking about usually occurs in importing data from a spreadsheet:
example:

MONTH PRODUCT SALES PRODUCT SALES

JAN            COKE            100        PEPSI         100
FEB            COKE             300        PEPSI        200

The output needed is:
PRODUCT JAN FEB

COKE          100       300
PEPSI           100       200

Look at the number columns here, they get transposed. That is what I wanted without an intermediate representation (in physical form, an in-memory form is acceptable). The reason being,materialzed forms can be too costly for huge input data.
Thanks
Aakash

"harakiri" <vadic1_at_home.com> wrote in message news:7etG6.27329$Jh5.24585715_at_news1.rdc1.sfba.home.com...
>
> "Aakash Bordia" <a_bordia_at_hotmail.com> wrote in message
> news:9ccmcp$fnq$1_at_stlnews.stl.ibm.com...
> > Agreed, but if you could give me a practical example of such a
 situation,
> > that would be super.
>
> Nothing new here, you already mentioned it in your mail.
>
> Source table:
>
> date | traffic
> ------------
> 1/1 | 12
> 1/2 | 55
> ...
> 2/1 | 34
> ...
>
> is the representation that a sane database schema designer would choose
 over
> some goofy schema like this:
>
> Day | Jan | Feb | ...
> -------------------
> 1 | 12 | 55
> 2 | 34
>
> (I understand, though, that this is report your customersw want:-) I
 agree,
> however, that transforming former into latter not much simpler task than
> transposing a matrix.... You'll have to resort to warehousing extensions
 ala
> "create dimension"...
>
>
Received on Mon Apr 30 2001 - 20:56:34 CEST

Original text of this message