Looking for SQL to Display Rows as Columns in a View

Hi!
I am using Oracle 10g (10.1.0.4.0) 64 bit on Red Hat Enterprise Linux AS release 3.
I have the following tables:
Table A
A_ID number (primary key)
Table B
B_ID number (primary key)
B_NAME varchar2
B_DESC varchar2
Table C
C_ID number (primary key)
B_ID number (foreign key to table B)
A_ID number (foreign key to table A)
ORDERING number
A row in table A can have from 0 (zero) to 3 (three) rows in table C associated with it.
I am trying to make a view that displays A.A_ID and its associated rows from table C as a single row. For example, the following query:
select A.A_ID, C.B_ID, B.B_NAME, B.B_DESC, C.ORDERING
  from C, B, A
where C.A_ID = A.A_ID
   and C.B_ID = B.B_IDYields the following results:
A_ID B_ID B_NAME B_DESC ORDERING
100   10 A      One    1
100   20 B      Two    2
100   30 C      Three  3I would like to get the following:
A_ID B_NAME_1 B_NAME_2 B_NAME_3
100 A        B        CThanks (in advance :-),
Avi.

SQL> CREATE TABLE dt_test_a(a_id number)
  2  /
Table created.
SQL> CREATE TABLE dt_test_b(b_id number, b_name varchar2(1),b_desc varchar2(10))
  2  /
Table created.
SQL> CREATE TABLE dt_test_c(c_id number, b_id number, a_id number, ordering number)
  2  /
Table created.
SQL>
SQL> insert into dt_test_a values(100)
  2  /
1 row created.
SQL> insert into dt_test_b values(10, 'A','One')
  2  /
1 row created.
SQL> insert into dt_test_b values(20, 'B','Two')
  2  /
1 row created.
SQL> insert into dt_test_b values(30, 'C','Three')
  2  /
1 row created.
SQL> insert into dt_test_c values(1, 10, 100, 1)
  2  /
1 row created.
SQL> insert into dt_test_c values(2, 20, 100, 2)
  2  /
1 row created.
SQL> insert into dt_test_c values(3, 30, 100, 3)
  2  /
1 row created.
SQL>
SQL> SELECT
  2     a.a_id,
  3     DECODE(c.ordering, 1, b.b_name) b_name_1,
  4     DECODE(c.ordering, 2, b.b_name) b_name_2,
  5     DECODE(c.ordering, 3, b.b_name) b_name_3
  6  FROM
  7     dt_test_a a,
  8     dt_test_b b,
  9     dt_test_c c
10  WHERE
11     a.a_id = c.a_id
12  AND
13     b.b_id = c.b_id
14  /
     A_ID B B B
      100 A
      100   B
      100     C
SQL>
SQL> SELECT
  2     a.a_id,
  3     MAX(DECODE(c.ordering, 1, b.b_name)) b_name_1,
  4     MAX(DECODE(c.ordering, 2, b.b_name)) b_name_2,
  5     MAX(DECODE(c.ordering, 3, b.b_name)) b_name_3
  6  FROM
  7     dt_test_a a,
  8     dt_test_b b,
  9     dt_test_c c
10  WHERE
11     a.a_id = c.a_id
12  AND
13     b.b_id = c.b_id
14  GROUP BY
15     a.a_id
16  /
     A_ID B B B
      100 A B C
SQL>
SQL>
SQL> insert into dt_test_a values(200)
  2  /
1 row created.
SQL> insert into dt_test_b values(40, 'A','One')
  2  /
1 row created.
SQL> insert into dt_test_b values(50, 'B','Two')
  2  /
1 row created.
SQL> insert into dt_test_b values(60, 'C','Three')
  2  /
1 row created.
SQL> insert into dt_test_c values(4, 40, 200, 3)
  2  /
1 row created.
SQL> insert into dt_test_c values(5, 50, 200, 2)
  2  /
1 row created.
SQL> insert into dt_test_c values(6, 60, 200, 1)
  2  /
1 row created.
SQL>
SQL> SELECT
  2     a.a_id,
  3     MAX(DECODE(c.ordering, 1, b.b_name)) b_name_1,
  4     MAX(DECODE(c.ordering, 2, b.b_name)) b_name_2,
  5     MAX(DECODE(c.ordering, 3, b.b_name)) b_name_3
  6  FROM
  7     dt_test_a a,
  8     dt_test_b b,
  9     dt_test_c c
10  WHERE
11     a.a_id = c.a_id
12  AND
13     b.b_id = c.b_id
14  GROUP BY
15     a.a_id
16  /
     A_ID B B B
      100 A B C
      200 C B A

Similar Messages

  • Can anybody help....SQL to display row as column and column as rows

    Can anybody help in writing a SQL to display row as column and column as rows?
    Thanks

    check this link:
    Re: Creating Views - from rows to a new column?

  • Sql to display rows like columns

    Hi,
    I am having table with 3 columns i.e col1, col2, col3
    and the values are :
    col1 col2 col3
    1 11 A
    1 11 B
    1 11 C
    2 22 P
    2 22 Q
    2 22 R
    2 22 S
    I require the output from the above data as follows :
    1 11 A B C
    2 22 P Q R S
    rows of col3 to be converted into column.
    Please suggest to get the about output thru SQL.
    Thanks
    Ramesh

    Ok, but you're not gonna like it.... (ignore the bit above the select statment as that is just setting up the test data)
    with t as (select 1 as col1, 11 as col2, 'a' as col3 from dual union
               select 1, 11, 'b' from dual union
               select 2, 22, 'j' from dual union
               select 2, 22, 'k' from dual union
               select 2, 22, 'l' from dual union
               select 2, 33, 'v' from dual)
    select col1, col2, max(col3_1)||max(col3_2)||max(col3_3)||max(col3_4)||max(col3_5)||max(col3_6)||max(col3_7)||max(col3_8)||max(col3_9)||max(col3_10) col3
    from  (
            select col1, col2, decode(row_number() over (partition by col1, col2 order by col1, col2), 1, col3, null) col3_1, null col3_2, null col3_3, null col3_4, null col3_5, null col3_6, null col3_7, null col3_8, null col3_9, null col3_10 from t union
            select col1, col2, null col3_1, decode(row_number() over (partition by col1, col2 order by col1, col2), 2, col3, null) col3_2, null col3_3, null col3_4, null col3_5, null col3_6, null col3_7, null col3_8, null col3_9, null col3_10 from t union
            select col1, col2, null col3_1, null col3_2, decode(row_number() over (partition by col1, col2 order by col1, col2), 3, col3, null) col3_3, null col3_4, null col3_5, null col3_6, null col3_7, null col3_8, null col3_9, null col3_10 from t union
            select col1, col2, null col3_1, null col3_2, null col3_3, decode(row_number() over (partition by col1, col2 order by col1, col2), 4, col3, null) col3_4, null col3_5, null col3_6, null col3_7, null col3_8, null col3_9, null col3_10 from t union
            select col1, col2, null col3_1, null col3_2, null col3_3, null col3_4, decode(row_number() over (partition by col1, col2 order by col1, col2), 5, col3, null) col3_5, null col3_6, null col3_7, null col3_8, null col3_9, null col3_10 from t union
            select col1, col2, null col3_1, null col3_2, null col3_3, null col3_4, null col3_5, decode(row_number() over (partition by col1, col2 order by col1, col2), 6, col3, null) col3_6, null col3_7, null col3_8, null col3_9, null col3_10 from t union
            select col1, col2, null col3_1, null col3_2, null col3_3, null col3_4, null col3_5, null col3_6, decode(row_number() over (partition by col1, col2 order by col1, col2), 7, col3, null) col3_7, null col3_8, null col3_9, null col3_10 from t union
            select col1, col2, null col3_1, null col3_2, null col3_3, null col3_4, null col3_5, null col3_6, null col3_7, decode(row_number() over (partition by col1, col2 order by col1, col2), 8, col3, null) col3_8, null col3_9, null col3_10 from t union
            select col1, col2, null col3_1, null col3_2, null col3_3, null col3_4, null col3_5, null col3_6, null col3_7, null col3_8, decode(row_number() over (partition by col1, col2 order by col1, col2), 9, col3, null) col3_9, null col3_10 from t union
            select col1, col2, null col3_1, null col3_2, null col3_3, null col3_4, null col3_5, null col3_6, null col3_7, null col3_8, null col3_9, decode(row_number() over (partition by col1, col2 order by col1, col2), 10, col3, null) col3_10 from t
          ) t
    group by col1, col2
          COL1       COL2 COL3
             2         33 v
             1         11 ab
             2         22 jkl
    SQL>

  • Need help in displaying Rows to Columns

    Hi,
    I am facing problem in displaying Rows to Columns
    I am using pivot function:
    select *
    from
    (select vendor_name
    from tablea)
    pivot
    (count(vendor_name)
    for vendor_name in ('a,b,'c'));
    its working fine showing vendor_name and count
    but when i want to display the output as:(How to include the Salalry column in the query?)
    Name:{a b c}
    Sal Total:(400,600,800}
    Any help will be needful for me

    Not sure what you mean:
    select  *
      from  (select deptno,sal from emp)
      pivot(sum(sal) for deptno in (10,20,30))
            10         20         30
          8750      10875       9400
    SQL> SY.

  • How do I write a macro that would look for a string in an entire column

    how do I write a macro that would look for a string in an entire column. If the string is found, it will copy that entire row to a new sheet in that same file?
    I want to look in an entire column lets say "C" for different strings of numbers like 246, 88, 68, 82246 etc... and copy them to a new sheet
    Thanks

    Hello Larbec,
    Try this:
    Option Explicit
    Sub test()
        Dim myNumber As Integer
        Dim myNumbers() As Integer
        Dim i As Integer
        Dim c As Range
        Dim firstAddress As Variant
        myNumbers = Array(246, 88, 68, 82246)
        For i = 0 To UBound(myNumbers)
            myNumber = myNumbers(i)
            With ActiveSheet.Range("C:C")
                Set c = .Find(myNumber, LookIn:=xlValues)
                If Not c Is Nothing Then
                    firstAddress = c.Address
                    Do
        ' Copy c.value to OtherSheet here !!!!
                        Set c = .FindNext(c)
                    Loop While Not c Is Nothing And c.Address <> firstAddress
                End If
            End With
        Next i
    End Sub
    Best regards George

  • How to display Rows as Columns in JSF?

    I am using dataTable component to get data for my Menu, i have one column in it which returns me the data, because its automatically adding <tr> and <td> tags to it, its showing data in tabular form.
    I want to show output Horizontally instead of Vertically the way its showing.
    Is their any way i can display Rows as Columns?
    Code:
    ==============================================
    <div class="bodyarea">
    <div id="location">
    <h:dataTable value="#{menuItem.breadCrumb}" var="bread" >
    <f:verbatim><ol></f:verbatim>
    <h:column>
    <f:verbatim><li></f:verbatim>
    <h:outputLink id="crumbID" value="#{bread.menuLink}">
    <h:outputText id="crumpName" value="#{bread.menuLabel}"/>
    </h:outputLink>
    <f:verbatim></li></f:verbatim>
    </h:column>
    <f:verbatim></ol></f:verbatim>
    </h:dataTable>
    </div>
    </div>
    Thank you

    Table is not the html element for you, in this situation.
    I would use a dataList component (distributed with myfaces implementation).
    dataList is able to return a list of item, and using css you will be able display in a horizontal grid. (otherwise you can use layout="grid" in dataList).
    Anyway...my impression is that who made JSF was not really understanding how a html programmer like to write his code.
    Why do JSF gives us only the possibility to write list of items throught tables?
    Why do JSF prints error messages throught tables?
    Why div is not a standard component?
    This is an incredible lack...
    I see also other incredible lasks...but they don't concern html ;) .

  • Looking for SQL*Net for Windows 95

    I have Brio client installed on my laptop running Windows 98. I am looking for SQL *Net for Windows 95, to connect to an Oracle database running on Solaris.  Where can I find it.
    How do I connect? I tried MS ODBC and it did not work.
    Please help
    My email address is [email protected]
    Thanks in advance

    despite that I do not know the type of the Firewall , I was able to adjust Oracle with Microsoft ISA server as follows :
    go to oracle server on Windows 2000
    open system variables
    insert the following variable : USE_SHARED_SOCKET
    make its value : TRUE
    restart server
    this variable will make you able to share ports on windows platform ,, this is essential because Oracle servers replies back on any port randomly when trying to connect to it ,, you can track this by enabling tracing for listener.
    on firewall you will need to redirect connection received by the firewall on specific port on the firewall and NAT it to Oracle server IP/port .
    this is proven work
    on UNIX you do not need this beacsue Unix natively share ports.

  • IF NEW VARIABLE IN SQL QUERY, DISPLAYS AS LAST COLUMN + rpad not working

    Hello everybody and thank you in advance,
    1) if I add a new variable to my sql query to select a column which was already in the table, it shows it in the report table as the Last column to the right. That is, if I add "street" to
    something like city, postcode, street, store, manager, etc, instead of placing street between postcode and store, it places it as i said as the last column to the right.
    2) When values are entered into the cells of the tables, yes, they do expand it to their needed lenght, But, only if it is one word. If it is two, like when i enter the value "very good"
    then it takes two lines so as with a carriage return within the cell, thus, making it too high the row. I tried to padd spaces with rpad but it did not work. something like rpad(stock, 20,' ')
    I must say that the table is in the same page where there is a Form, so as the table grows in lenth it is actually squeezing the form located right on its left.
    3) rpad did not work with the most simple syntax, but less would with what i need because it turns out i am using DECODE in order to do a conversion between value displayed and
    value returned in my select list of values, something like : DECODE (TO_CHAR (stock),'1','Deficient','2','Average','3','Good','4','Very Good',null) AS stock,
    so, i have tried to put the rpad there in several places but either it gave parsing error or it left the column empty not picking any values.
    thank you very much
    Alvaro

    Alvaro
    1) That is standard behaviour of apex builder. You can change the display order with the arrows in the report attributes column report.
    2) You will have to play with the style attributes of the column to accomplice this. For instance style="white-space:pre;" in the Element Attributes of the column attributes. White-space:normal would thread several space (' ') as 1. So no matter how many you add with rpad they will be shown as 1.
    Or set a width either as attibute or in a style class for that column.
    Nicolette

  • Looking for SQL Solution to Very Unique Problem

    Hello,
    New here, thanks. I have what I think is an interesting problem. I really don't want to post it because the background and explanation is rather lengthy. It has to do with one table that holds some general info; there is a unique numeric primary key. Associated with this table are three different tables identical in structure, having only two fields: the primary key, and a code. The three tables correspond to test results performed by a different individual. For each entry in the main table, where there is one and only one entry for the primary key, the same test could have been performed one, two, or three times. So there could be one, two, or three different sets of codes describing the test results. Only one set of the test result codes is the correct one. And there is a hierarchy that determines which is the correct set of codes. Say the main table is called LR. LR is linked to three different tables, each of which has the exact same structure. The relationship between LR and each of these three tables is one to many. Call the three tables that hold test results SCR, QC, and PT. Some assumptions can be made. In the table LR there are two flag fields: Q_STATUS and P_STATUS whose values each are either Y or N. If P_STATUS=Y, then we are guaranteed a set of test result codes in the table PT, and this set of codes is always the final word; always the correct results. If P_STATUS=N but Q_STATUS=Y, then we are guaranteed to have a set of test result codes in the table QC, and if this is the case, then this set of codes is the final word. Now if P_STATUS=N and Q_STATUS=N, then we know there is a set of test result codes in the SCR table, we know there is one and only one set of test result codes, hence this set is the correct one. Another assumption that can be made, for any row in the LR table, there will ALWAYS be at least one set of test result codes in the SCR table. There may or may not be a set of test result codes in the QC and PT tables, and the flags in the LR table indicate if either is the case. Hope this makes sense so far. For many years I have been trying to figure out one SQL statement that will return the correct set of test result codes. Often I have to analyze data that relies on the results of a test (e.g. how many tests had the code 850 in the year 2011?). That's a simple example, but you get the idea. Since I have to determine which set of test result codes is the correct one to use, I've always had to rely on writing a PL/SQL procedure anytime I have to work with test result codes. I tend to use a conditional: IF (P_STATUS=Y) THEN /*the right answer is in the table PT*/ ELSIF (Q_STATUS=Y) THEN /*the right answer is in the table QC*/ ELSE /*the right answer is in the table SCR*/. I have a document with a little more detail, and an example. Or maybe this makes absolute sense to someone out there and they know exactly what to tell me! And let me say this is not a critical issue for me. I've been searching for this SQL statement for about 10 years now. I consider myself pretty proficient with SQL, but definitely not a guru. I'm thinking the solution I'm looking for might rely one some kind of full outer join on all three of the tables SCR, QC, and PT and then if those results could be linked to the LR table, and then maybe in the SQL statement use of DECODE might do it. I want one SQL statement that will return me the correct set of testing result codes. Hope this all makes sense. To anyone who has read it I thank you very much. I would be very happy to provide my document with further explanation and an example. Any response is greatly appreciated. Guess I have to keep coming back here now to see if anyone responded. Oh, I might add that we use a very old version of Oracle (8.0.3) but, if all goes according to plan, we should migrate to the most current version within the next year.
    Thanks,
    John Cardella
    Edited by: BluShadow on 21-Feb-2012 13:52
    Email address removed for your own benefit, unless of course you'd like spam bots to pick it up and send you lots of rubbish?

    Why do I keep three tables. Each sample that is evaluated is always screened by what I will call a "tech." Every so many cases the test must be repeated for quality control. If the findings of the initial testing or of a quality control test are found to contain abnormal results, then the test must also be repeated, this time looked at by a doctor. So I have what I refer to as the "main" table; the one that holds final data, which in my example I explained the two "flag" fields that indicate if the test was repeated. Every time a test is evaluated it is done by the same person, and the findings of an individual testing, or screening, are a set of test result codes. There is the "main" control table which I have called LR in my example. The reason I have the other three tables: one is used to store the test results of the initial screening (always done); one is used to hold the test results of a quality control case (may or may not be done); and one is used to hold the test results of an abnormal case that was screened by a doctor (may or may not be done). There is a separate table for each individual who may have done a screening.
    Let us consider the results of just one case. In the table LR we have something like this:
    | KEY | P_STATUS | Q_STATUS |
    | 100 | Y | Y |
    By default, for any entry in the LR table there is always a set of codes in the SCR table. We know a quality control was performed because QC_STATUS=Y, and we know it was screened by a doctor because P_STATUS=Y. So we would have three different sets of findings, each in one of the three tables:
    SCR TABLE: QC TABLE:
    | KEY | CODE | | KEY | CODE | | KEY | CODE |
    | 100 | 014 | | 100 | 13R | | 100 | 13R |
    | 100 | 13R | | 100 | 150 | | 100 | 170 |
    | 100 | 150 | | 100 | 170 | | 100 | 180 |
    | 100 | 160 | | 100 | 190 |
    The values in the three tables represent the findings of three different people who screened the test sample. Now suppose I combined all the data, I would suppose it would look something like this:
    | KEY | P_STATUS | Q_STATUS | KEY | CODE | KEY | CODE | KEY | CODE |
    | 100 | Y | Y | 100 | 014 | null | null | null | null |
    | 100 | Y | Y | 100 | 13R | 100 | 13R | 100 | 13R |
    | 100 | Y | Y | 100 | 150 | 100 | 150 | null | null |
    | 100 | Y | Y | 100 | 160 | null | null | null | null |
    | 100 | Y | Y | null | null | 100 | 170 | 100 | 170 |
    | 100 | Y | Y | null | null | null | null | 100 | 180 |
    | 100 | Y | Y | null | null | null | null | 100 | 190 |
    Since P_STATUS=Y I would want the result set returned to be {13R, 170, 180, 190}.
    But suppose P_STATUS=N and Q_STATUS=Y then I would want the result set to be {13R, 150, 170}
    And if P_STATUS=N and Q_STATUS=N then I would want {014, 13R, 150, 160}
    Of all of the sets of test results codes, only ONE is ever the final word (i.e. the right answer).
    So what I was trying to do is find a query that would give me what I want. And my apologies if there is a major design flaw. I always thought it was not that bad. But then I am no SQL guru either.
    To anyone who has read on further my most humble thanks. I really did not mean to waste anyone's time or be a pain in the ass.
    Thanks Again,
    -JC

  • Displaying Row and Column Numbers

    I see through other research on Oracle SQL Developer that I should be able to display the row and column numbers on version 1.5.4, but I don't see where to go to turn this on. Suggestions?

    Suggestions?Ask in the SQL Developer forum?

  • Setup for discoverer table for showing number of Rows and columns of Report

    As oracle discoverer report show "Rows 1-25 of"(Total rows) and "Column 1-6 Of"(Total Column).
    This total rows and columns information's is not appearing on our reports.
    Kindly let us know its setting/setups .
    This is very urgent to us, Any help will be highly appreciated.
    Thanks, Avaneesh

    Hmm, what version of Discoverer are you on? Do I understand you correctly that you are able to run a Discoverer report and see this rows and columns information? What software are you running when you do this - Viewer, Plus, or Desktop? Where is this showing up - the top of the report maybe? Or maybe the bottom of the report? The only thing I can think of to handle this is the Page Setup for a workbook, and looking at the Header and Footer sections of that setup. But I am on Discoverer 10.1.2.2 and I don't see anything I can insert on the header/footer that would show this kind of information. Desktop will let you do Page x of y pages (Plus does not), but that is not what you are seeing. You can maybe look at the page setup and see if there is something there not documented in the Discoverer guides.
    John Dickey

  • Looking for Fm which display Blocked status

    Hi ,
    I was looking for a function module which displays the  blocked status in GTS system, i know one '/SAPSLL/CD_STATUS_GET' which exist ECC system, but i am looking for which is in GTS system.
    Could you plz help me out with this issue.

    Hi Ashok
    To answer your question some more context would be useful.  What inputs do you have to identify the document?  The reference document -OR- GTS customs document?  There are lots of standard function modules available such as /SAPSLL/CUHDSTA_DB_SGL_READ which provides the customs document header statuses for SPL, License and Embargo checks from the document header status table directly.  The inputs for this would be the GUID from table CUHD.
    The function module used when ECC calls GTS using /SAPSLL/CD_STATUS_GET is /SAPSLL/API_6800_STATUS_GET, this is another possibility. 
    Hope that helps.
    Rachael

  • Display rows to columns

    User require a report having the following column data should be populated in column instead of row.
    how can i modify or where should i modify to get the required output below. the following query is in XML file
    select awd.award_id,
                        award_number,
              bond_name,
              p2b.bond_id bond_id,
              nvl(b.par_amount,0)+nvl(b.premium,0)+nvl(b.original_issue_discount,0)+nvl(b.bic,0) Total_proceeds,
              p2b.earnings_proceeds earning_procs,          
              nvl(b.original_issue_discount,0)+nvl(b.bic,0) issuance_cost
              FROM   xxdl.xxdl_cd_bond_setup_new b,
                      (select  bond_id,
                        effective_date,nvl(earnings_proceeds,0) earnings_proceeds
                                    from  (
                         select  s.*,
                                   row_number() over(partition by bond_id order by effective_date desc) rn
                           from  XXDL.xxdl_cd_bond_schedk_p2b s
                where rn = 1) p2b,
                      gms_awards_all awd
                        WHERE  b.bond_id= p2b.bond_id(+)
                        AND b.award_id = awd.award_id(+)
                        AND b.award_id = decode(:P_award_num,null,b.award_id,:P_award_num)
    Actual output
    award_id   award_number  bond_name bond_id       Total_proceeds              issuance_cost
    345     XI         ABC            null                 100           40
    234     XIIA        DEF             null                 86                      100
    Expected output
    345     234
    XI     XIIA
    ABC     DEF 
    null       null
      100           86
    40             100Edited by: 893185 on Nov 9, 2011 4:14 PM

    4. How do I convert rows to columns?
    SQL and PL/SQL FAQ

  • Looking for SQL*Loader sample file

    Hi all,
    I'm looking for a sample SQL*Loader file that I could use to populate the Bank Statement Interface in Cash Management (Receivables Lockbox Receipts) - specifically CE_STATEMENT_HEADERS_INT_ALL and CE_STATEMENT_LINES_INTERFACE.
    I'm trying to put together an interface from Bank of America's Lockbox into our Oracle Receivables system (11.0.3), and don't have access to anything from which to start from.
    Thanks in Advance,
    Cam

    check it
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch10.htm#1656
    kuljeet pal singh

  • Looking for SQL*NET Proxy

    Hello,
    i'm looking for the SQL*NET proxy because i want to integrate into out firewall software. I'm looking for a contact too. Nobody knows anything about this product.
    With best regards
    Claus Rosenberger

    despite that I do not know the type of the Firewall , I was able to adjust Oracle with Microsoft ISA server as follows :
    go to oracle server on Windows 2000
    open system variables
    insert the following variable : USE_SHARED_SOCKET
    make its value : TRUE
    restart server
    this variable will make you able to share ports on windows platform ,, this is essential because Oracle servers replies back on any port randomly when trying to connect to it ,, you can track this by enabling tracing for listener.
    on firewall you will need to redirect connection received by the firewall on specific port on the firewall and NAT it to Oracle server IP/port .
    this is proven work
    on UNIX you do not need this beacsue Unix natively share ports.

Maybe you are looking for