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 -> Need help writing SQL Query

Need help writing SQL Query

From: Enzo Maini <maini_at_earthlink.net>
Date: Sat, 19 Jul 2003 03:38:12 GMT
Message-ID: <E23Sa.108945$Io.9311350@newsread2.prod.itd.earthlink.net>


I have two tables,

  Table A (

      TabAID number
      ColA varchar,
      ColB number

  )

   Table B (

       TabBID number,
       TabAID number,
       ColX  varchar,
       ColZ  varchar

)

Table A Values:

TabAID ColA ColB
---------- ------- --------

1001       DHL   2000
1002       UPS   2500

Table B Values:

TabBID TabAID  ColX                   ColZ
----------- ----------- --------                  ------------
5000      1001     Freight Charge   100
5001       1001    Max Weight          70
5002       1002    Freight Charge    100
5003        1002   Max Weight           55


ColX in Table B is really a column name and ColZ holds the value. Note, that the values
in Table B will grow over time meaning more columns will be returned

Is there a way to write a query such that it returns a row like this in SQLPlus

ColA ColB "Freight Charge" "Weight"

-------  -------  ----------------------------  -----------------
DHL   2000   100                                70
UPS   2500    100                               55

Esentially I need a cross-tab and some how merge that with a regular standard select

Thanks Received on Fri Jul 18 2003 - 22:38:12 CDT

Original text of this message

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