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

Home -> Community -> Usenet -> c.d.o.server -> No true Crosstab Query in Oracle???

No true Crosstab Query in Oracle???

From: John W <John.Wisnieff_at_oracle.com>
Date: Fri, 22 Nov 2002 16:33:29 -0800
Message-ID: <T7AD9.16$lF3.141@news.oracle.com>


I need to do a crosstab query in Oracle where the values from one field become the column headers in the final query result. An example of this is taking a table that looks like:

sample_id, test_desc, result

1, Moisture, 23.4
1, Carbon, 32.5
1, Sulfur, .0023
2, Moisture, 54.2
2, Carbon, 12.2
2, Sulfur,
3, Sulfur, .023

and returning a result that looks like this:

sample_id, Moisture, Carbon, Sulfur, ...

1, 23.4, 23.4, 32.5, .0023
2, 54.2, 12.2,
3, , , .023


However I find no crosstab functionality in Oracle. All I see in researching this is a technique to manually create a DECODE statement for a fixed number of columns. Since the number of columns for this query can vary this option will not work and this technique is not a true crosstab query. Does anyone know of a way to do a crosstab query in Oracle similar to those that can be done by desktop databases such as Paradox or MS Acesss? Thanks Received on Fri Nov 22 2002 - 18:33:29 CST

Original text of this message

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