Need Help in Union of Columns in FX

Hello Experts,
In database I have a table having two columns, Version From, Version To.
Column "Version Start" data is like
V0, V1, V2, V3, V4....upto V11 (fixed value)
Column "Version End" data is like
V1, V2, V3..... upto V11 (fixed value V0 is not present)
User requirement is like create two prompts on these columns and select the data
between these two fields and see the report. This is achieved by prompt and presentation variable.
But the problem is let say user select V1 from Version Start, then Version End prompt should show all values apart from V1.
If user select V2 then it should all value in Version End apart from V2.
I tried but it seems 'union' function does not work in rpd bmm, nor in fx in OBIEE 10g.
Can you all please help.
Thanks

The easiest way to do this, and it could be done in a few minutes, would be to move to a currently supported version of Oracle, 11gR1 or 11gR2, where we have the PIVOT and UNPIVOT operators.
In the desupported version you have the best choice is to hit http://asktom.oracle.com and look up the solution he published there some years ago.
I don't have the link so you can find it as fast as I can but look under "pivot" and "crosstab."

Similar Messages

  • Need help in writing NVARCHAR2 column to an excel sheet

    Hi All,
    I have a NVARCHAR2 column in my table. I want to store the data present in the column into an excel file. When i write the data to an excel file the data is getting converted to some other form. It's not in human readable form.
    Language is not fixed for the column.
    I need help in storing the NVARCHAR2 data into an excel file without any implicit conversion done by the oracle.
    Please help.
    Thanks,
    Girish G
    Edited by: Girish G on Jul 14, 2011 2:02 AM

    Export data to BLOB (csv)

  • Need help on getting the column names of Tabletype

    I have a table Mapping with the following values: This Mapping table contains the table names (in Tabname) and the column names(colname) of various tables and values(ValuesTobeFilled) for the columns.
    I have to insert into the tables present in the Tabname field with the values present in the ValuesTobeFilled in the columns present in the Colname field.
    Note: The Mapping table need not contain all the columns of the base table. The columns that are not present can be filled with null. And this mapping table is not fixed i.e. rows can be inserted/deleted frequently.
    Sample values in mapping table:
    Tabname                        Colname        ValuesTobeFilled
    sample_items     Eno     Corresponding Expression to get the values from XML input
    sample_items     Ename     Corresponding Expression to get the values from XML input
    XXX     YYY     Corresponding Expression to get the values from XML input
    Before filling in the actual tables, I have to store the entire data temporarily and I have used a tabletype declared as follows:
    TYPE T_sample_items IS TABLE OF sample_items%ROWTYPE INDEX BY BINARY_INTEGER;
    l_sample_items T_sample_items;
    Where the table sample_items have the following columns:
    •     Eno
    •     Ename
    •     Eaddress
    •     Eemail
    So, the tabletype should be filled as:
    Eno     Ename     Eaddress     EEmail
    1     XXX     -     -
    I have declared a cursor to select the values from mapping table and I need to fill in the ValuesTobeFilled values to the corresponding table.
    CURSOR c_xpath (c_tname mapping.TABNAME%type)
    IS
    select * from mapping where tabname = c_tname;
    CURSOR c_tables
    IS
    SELECT DISTINCT TABNAME FROM mapping;
    FOR crsr IN c_tables
    LOOP
    p_tname := CRSR.TABNAME;
    FOR csr IN c_xpath(p_tname)
    LOOP
    IF l_xml_doc.EXISTSNODE(CSR.XPATH_EXP) = 1
    THEN
    l_node_value := l_xml_doc.extract(CSR.XPATH_EXP).getStringVal(); -- This is the value to be stored in the corresponding column
    ELSE
         l_node_value := NULL;
    END IF;
    IF CSR.COLUMN_NAME = ‘eno’
    THEN
         l_sample_items(1).eno := l_node_value;
    ELSIF CSR.COLUMN_NAME = ‘ename’
    THEN
         l_sample_items(1).name := l_node_value;
    END IF;
    END LOOP;
    END LOOP;      
    And I need to eliminate hard coding while comparing the column names (in the following piece of code) as the Mapping table values are subject to insertion/deletion:
    IF CSR.COLUMN_NAME = ‘eno’
    THEN
         l_sample_items(1).eno := l_node_value;
    ELSIF CSR.COLUMN_NAME = ‘ename’
    THEN
         l_sample_items(1).ename := l_node_value;
    END IF;
    I need to insert the values directly into the tabletype without this hardcoding. Please suggest me ways to compare the mapping table values with the field (column) names of the tabletype. If it is not possible using tabletype, please suggest any other ways of fixing the problem.
    Many thanks,
    Gopi

    I take it this isn't going to be a serious production system at the end of the day?
    Storing metadata in tables for extraction and insertion of data is just wrong in so many ways. It smells heavily of Entity Attribute Value modelling, which is the most wrong way to use a relational database and is known to have major performance implications and be liable to bugs and issues. The idea that EAV modelling allows for 'generic' databases where new data items can be added flexibly later on without having to change code is usually justified with an excuse of "it means we don't have to update all our tables when we want a new column" which is easily countered with "if you're adding a single column a good relational design wouldn't require you to add it to more than one table anyway in most cases".
    Just what exactly are you trying to do and why? There has to be a better way.

  • Need help with a calculated column - is there any way to reference a value in the current row?

    Hey guys,
    I'm a bit of a DAX newbie, and I'm running into a block. I'm creating a Power View report about IT tickets. We are going to be creating a cube to automate the data soon, I'm currently working with a flat Excel Data Table of data to demonstrate the Power
    View reporting capabilities to the team. I need the default display to show the top 4-5 items basked on the Ticket Count. The three applicable columns I'm using are the TicketID, the ContactReason, and the AssetCategory - all three are
    text. One slide will show the top five Contact Reasons by Ticket Count, and the other will show the top five Categories by Ticket Count. The users will see this default view, but will be able to change it to see differently ranked items or can clear the
    ranking slicer altogether.
    What I've accomplished so far is to create the Calculated Field [Ticket Count] = COUNTA(Table1[TicketID])
    And 2 other calculated fields:
    [Contact Rank] = RANKX(ALL(Table1[ContactReason]),[Ticket Count],,,DENSE)
    [Asset Rank] = RANKX(ALL(Table1[AssetCategory]),[Ticket Count],,,DENSE)
    If I were creating a Pivot Table, this would be great. These fields calculate everything the right way. The problem is, I need to have a Rank slicer on each slide and the calculation by itself contains no data - with no data, there's nothing to slice. I
    realized I need to actually have columns of data so I can create a slicer. I need each row of the table to show the same [Contact Rank] for every instance of a particular ContactReason (and the same for the [Asset Rank] and AssetCategory).
    The RANKX formulas pasted into the Calculated Column section only show a value of 1 - with no Pivot table summarizing the fields, it's counting each row's ticket once, giving every line the tied Rank of #1.
    I've solved the problem in Excel by creating 2 Pivot Tables on a separate sheet that have the data field and the calculated field for ContactRason and AssetCategory. Then on my Excel Data Table, I've added two columns that do a VLOOKUP and pull over a the
    Calculated Rank from each Pivot Table that match the ContactReason and AssetCategory fields. This works on the flat Excel Data Table now, but will not be a solutions when we start pulling the data from the cube (and there is no flat table).
    What I think I need is an Expression for the RANKX formula that can give me, for each row, the count of all of the times a ContactReason shows up in an entire column. There's only about 100,000 lines of data and each ContactReason or AssetCategory
    may show up several thousand times. But if I can get the expression to return that count, then the RANKX formula should work in the Column. If it wasn't a DAX formula, I'd use a COUNTIF and say 'Count the entire ContactReason column anytime it's equal to the
    ContactReason on THIS row', but in DAX I don't know how to reference a single value in a row. I've tried the CALCULATE() formula, but it seems like the filter needs a specific value, and doesn't work on a dynamic "cell" value.
    Any help would be greatly appreciated! (I hope it all makes sense!)

    If I've understood you correctly then the ALLEXCEPT function may be what you're after and it could be applied in a similar way to the following...
    =
    RANKX(
    ALL(Table1),
    CALCULATE(
    COUNTROWS(table1),
    ALLEXCEPT(Table1, Table1[ContactReason])
    DENSE
    If this has missed the mark, would it be possible to clarify the requirement further?
    Regards,
    Michael Amadi
    Please use the 'Mark as answer' link to mark a post that answers your question. If you find a reply helpful, please remember to vote it as helpful :)
    Website: http://www.nimblelearn.com
    Blog: http://www.nimblelearn.com/blog
    Twitter: @nimblelearn

  • Need help in sorting a column in classic report

    Hi I am trying to create and classic report and I need to do sorting on the columns. Also I am using a select list to filter the records in the column. When I am not using the select list the sorting is working but when I am using the selcet list and select the sort option then it is showing error. Can anyone help...
    Thnaks,
    Rik

    Select lists prior to v4 will sort on the return value. In v4, it sorts on the display value (as you're probably expecting). There's nothing really for you to fix here except if it's really important, see if you can get upgraded to v4.

  • Need help in modifying the column length

    Hi Experts,
    I need to modify the length of a column from char(10) to char(5), but it's showing the error of:
    ALTER TABLE appr_group_table MODIFY (APPR_TBLNO CHAR(5)) It's showing the below error:
    ERROR at line 1:
    ORA-01441: cannot decrease column length because some value is too bigI've checked in the dbase but there is no any value of this column having more than 5 characters:
    SQL> SELECT APPR_TBLNO FROM appr_group_table;
    APPR_TBLNO
    ANTAB
    ANTAB
    ANTST
    SCCTR
    SOTAB
    SOTAB
    SOTAB
    SOTAB
    SOTAB
    SOTAB
    SOTAB
    11 rows selected.Thnx in advance for helping me out.....

    char means fixed length variable. when you say char(10) oracle will reserve 10 places for your data. that means in your output what you are seeing as blank spaces are also considered as data. that is the reason, it is not allowing you to reduce the size.
    better solution is to create new column with varchar2 or char(5) datatype and transfer this column data into new column and then drop original column.

  • Need Help on Filtering a column

    Hi below is my requirement.
    ColA ColB ColB
    In the above, both the column 2 and 3 are the same columns, but i need to filter the column 3 alone based on another column. Please help.

    Hi,
    Write a case statement on 3rd column ...
    case when table1.status = 'Complete' then value(2nd col) end
    or
    case when table1.status = 'Complete' then value(2nd col) else null end
    Updated Post
    Can you paste your code (case statement)
    case when table_name.status ='Complete' then table_name.value end
    or
    case when table_name.status ='Complete' then table_name.value else null end
    Cheers,
    Aravind
    Edited by: Aravind Addala on May 17, 2011 11:48 PM

  • Need help with union of two selects

    select 1 selects items for a timespan.
    But if there is nothing found at one date,
    the date is not returned so I want a union with a calendar table
    Both selects work but how to make the union?
    Thanks for any help!
    select 1:
    SELECT COUNT(*) COUNT,
    fb_operation prodstep,
    kalenderwoche datum
    FROM stoerung,
    kalender
    WHERE str_kommenzeit > to_date('13.06.2006', 'dd.mm.yyyy')
    AND str_kommenzeit < to_date('11.07.2006', 'dd.mm.yyyy')
    AND to_char(str_kommenzeit,'dd.mm.yyyy') = to_char(fulldate,'dd.mm.yyyy')
    GROUP BY fb_operation,
    kalenderwoche
    ORDER BY fb_operation,
    kalenderwoche
    select 2:
    SELECT kalenderwoche datum
    from kalender
    WHERE fulldate > to_date('13.06.2006', 'dd.mm.yyyy')
    AND fulldate < to_date('11.07.2006', 'dd.mm.yyyy')

    THANKS A LOT!
    I tested it and it gave me good results
    the problem I still have is that then I expand the Date to
    to_date('11.12.2006') I just get the weeks
    that contain data. But I need all weeks that are selected, if there is
    no data the other fields shall be null or 0.
    This is much too difficult for me perhaps you can also help me with this!
    select * from
    (SELECT COUNT(*) COUNT,
    fb_operation prodstep,
    kalenderwoche datum
    FROM stoerung,
    kalender
    WHERE str_kommenzeit > to_date('13.06.2006', 'dd.mm.yyyy')
    AND str_kommenzeit < to_date('11.12.2006', 'dd.mm.yyyy')
    AND to_char(str_kommenzeit,'dd.mm.yyyy') = to_char(fulldate,'dd.mm.yyyy')
    GROUP BY fb_operation,
    kalenderwoche
    ORDER BY fb_operation,
    kalenderwoche) A,
    (SELECT kalenderwoche datum
    from kalender
    WHERE fulldate > to_date('13.06.2006', 'dd.mm.yyyy')
    AND fulldate < to_date('11.12.2006', 'dd.mm.yyyy') ) B
    where A.datum = B.datum (+)

  • Need help for the query columns to rows

    Hi everyone,
    I have two tables TABLE1 and TABLE2; TABLE1 is Master table,TABLE2 is child table.
    The key for TABLE1 is C1 column
    The key for TABLE2 is C1,C_MONTH Columns
    The sample data is as follows
    TABLE1
    ======
    C1 C2
    1 A
    2 B
    3 C
    4 D
    TABLE2
    ======
    C1 C_MONTH C3
    1 JAN AAA
    1 FEB BBB
    1 MAR CCC
    1 APR DDD
    2 JAN ZZZ
    2 FEB YYY
    2 MAR XXX
    2 APR UUU
    I want to display the data as follows
    1 A JAN AAA FEB BBB MAR CCC APR DDD
    2 B JAN ZZZ FEB YYY MAR XXX APR UUU
    Can any one help me how to write this query?
    Thanks in advance

    [email protected] wrote:
    Thanks for the update
    but I want the out put as column values rather than one column as follows
    C1 C2 J_MONTH J_VALUE F_MONTH F_VALUE M_MONTH M_VALUE A_MONTH A_VALUE
    1 A JAN AAA FEB BBB MAR CCC APR DDD
    2 B JAN ZZZ FEB YYY MAR XXX APR UUUThis is a standard pivot.
    In 10g or below you can do something like...
    SQL> ed
    Wrote file afiedt.buf
      1  with table1 as (
      2                  select 1 c1, 'A' c2 from dual union all
      3                  select 2, 'B' from dual union all
      4                  select 3, 'C' from dual union all
      5                  select 4, 'D' from dual
      6                 ),
      7       table2 as (
      8                  select 1 c1, 'JAN' C_MONTH,'AAA' C3 from dual union all
      9                  select 1,'FEB','BBB' C3 from dual union all
    10                  select 1,'MAR','CCC' C3 from dual union all
    11                  select 1,'APR','DDD' C3 from dual union all
    12                  select 2,'JAN','ZZZ' C3 from dual union all
    13                  select 2,'FEB','YYY' C3 from dual union all
    14                  select 2,'MAR','XXX' C3 from dual union all
    15                  select 2,'APR','UUU' C3 from dual
    16                 )
    17  -- end of test data
    18  select table1.c1, table1.c2
    19        ,max(decode(c_month, 'JAN', c_month)) as jan_month
    20        ,max(decode(c_month, 'JAN', c3)) as jan_value
    21        ,max(decode(c_month, 'FEB', c_month)) as feb_month
    22        ,max(decode(c_month, 'FEB', c3)) as feb_value
    23        ,max(decode(c_month, 'MAR', c_month)) as mar_month
    24        ,max(decode(c_month, 'MAR', c3)) as mar_value
    25        ,max(decode(c_month, 'APR', c_month)) as apr_month
    26        ,max(decode(c_month, 'APR', c3)) as apr_value
    27  from table1 join table2 on (table1.c1 = table2.c1)
    28* group by table1.c1, table1.c2
    SQL> /
            C1 C JAN JAN FEB FEB MAR MAR APR APR
             1 A JAN AAA FEB BBB MAR CCC APR DDD
             2 B JAN ZZZ FEB YYY MAR XXX APR UUU
    SQL>From 11g upwards you can use the new PIVOT keyword.

  • Need help in GROUPING of COLUMN Based Query

    Hi,
    I am facing problem in generating a scenario:
    I have built a Query like this:
    SELECT
    a.sal,
    a.country
    FROM
    employee a,
    department d
    WHERE
    a.dept_code=b.dept_code
    I want the query where the Query will produce a result set based on SALARY based on COUNTRY.
    For example if the COUNTRY is US then it will show the breaking of SALARIES.If the COUNTRY is NON US it will club the SALRIES
    Any help will be needful for me

    Hi,
    Here's one way:
    SELECT       deptno
    ,       SUM (sal)     AS sal
    FROM       scott.emp
    GROUP BY  deptno
    ,            CASE
               WHEN  deptno = 30
               THEN  empno
           END
    ORDER BY  deptno
    ;Output:
    `   DEPTNO        SAL
            10       8750
            20      10875
            30       1600
            30       1250
            30       1250
            30       2850
            30       1500
            30        950In the table, there are 3 rows with deptno=10, and 5 rows with deptno=20, but the CASE expression returns NULL for all of them, so there is only 1 sub-group for each of those deptnos.
    Edited by: Frank Kulash on Mar 13, 2013 5:41 AM
    This is essentially the same solution that Jeneesh already posted. (Sorry, I didn't see that before.)

  • Need help in hiding particular column of a table depending upon value

    Hi experts,
    I have developed a custom smartform and Print program.
    My problem is ..depending upon the data i recieve,...i have to hide a particular column.
    For example ... i have a table with 2 rows...one header and main row..This table has 3 column.
    I have to hide one of the column depending upon the data i recieve. So my output should have 2 rows and 2 columns.
    Please help.

    well vishwa u r right it wont work for multiple columns,
    then i guess this shud work.
    @thendral
    U can try like this create the rows with single column
    then print all ur text elements with spaces inserted manually between them with text editor then in conditions tab of the text elements specify ur condition according to what all u want to print.
    кu03B1ятu03B9к

  • Need help in SQL , Subtract column based on the condition in the Row

    Hi all ,
    I’m new to Sql Queries; I have a requirement which involves Sql query,
    Can anyone tell the How to proceed or provide me Sql
    Here goes the requirement
    Current Table
    ID |-|Month|-|Data
    1|-|Jan-10|-|10.00
    2|-|Feb-10|-|20.00
    3|-|Mar-10|-|30.00
    4|-|Apr-10|-|50.00
    5|-|May-10|-|60.00
    6|-|Jun-10|-|70.00
    7|-|Jul-10|-|100.00
    8|-|Aug-10|-|110.00
    9|-|Sep-10|-|120.00
    10|-|Oct-10|-|140.00
    11|-|Nov-10|-|150.00
    12|-|Dec-10|-|170.00
    13|-|Jan-09|-|180.67
    14|-|Feb-09|-|194.67
    15|-|Mar-09|-|208.67
    16|-|Apr-09|-|222.67
    Format needed
    ID |-|Month|-|Data|-|Base on this condition
    1|-|Jan-10|-|10.00|-|Jan 10
    2|-|Feb-10|-|10.00|-|Feb10-Jan10
    3|-|Mar-10|-|10.00|-|Mar10 - Feb10
    4|-|Apr-10|-|20.00|-|Apr10 - Mar10
    5|-|May-10|-|10.00|-|May10 - Apr10
    6|-|Jun-10|-|10.00|-|Jun10 - May10
    7|-|Jul-10|-|30.00|-|Jul10 - Aug10
    8|-|Aug-10|-|10.00|-|Aug10 - Jul10
    9|-|Sep-10|-|10.00|-|Sep10 -Aug10
    10|-|Oct-10|-|20.00|-|Oct10 -Sep10
    11|-|Nov-10|-|10.00|-|Nov10 - Oct10
    12|-|Dec-10|-|20.00|-|Dec10 - Nov10
    13|-|Jan-09|-|10.67|-|Jan 09
    14|-|Feb-09|-|14.00|-|Feb09-Jan09
    15|-|Mar-09|-|14.00|-|Mar09 - Feb09
    16|-|Apr-09|-|14.00|-|Apr09 - Mar09
    Thanks in advance
    Astle

    Welcome to the forum!
    this?
    select id
         , mon
         , data
         , data - lag (data, 1, 0) over (partition by trunc (mon, 'yyyy')
                   order by mon)
      from test
    order by idas in
    SQL> with test as
      2  (
      3  select 1 id ,to_date ('Jan-10', 'Mon-rr') mon,10.00 data from dual union all
      4  select 2,to_date ('Feb-10', 'Mon-rr'),20.00 data from dual union all
      5  select 3,to_date ('Mar-10', 'Mon-rr'),30.00 data from dual union all
      6  select 4,to_date ('Apr-10', 'Mon-rr'),50.00 data from dual union all
      7  select 5,to_date ('May-10', 'Mon-rr'),60.00 data from dual union all
      8  select 6,to_date ('Jun-10', 'Mon-rr'),70.00 data from dual union all
      9  select 7,to_date ('Jul-10', 'Mon-rr'),100.00 data from dual union all
    10  select 8,to_date ('Aug-10', 'Mon-rr'),110.00 data from dual union all
    11  select 9,to_date ('Sep-10', 'Mon-rr'),120.00 data from dual union all
    12  select 10,to_date ('Oct-10', 'Mon-rr'),140.00 data from dual union all
    13  select 11,to_date ('Nov-10', 'Mon-rr'),150.00 data from dual union all
    14  select 12,to_date ('Dec-10', 'Mon-rr'),170.00 data from dual union all
    15  select 13,to_date ('Jan-09', 'Mon-rr'),180.67 data from dual union all
    16  select 14,to_date ('Feb-09', 'Mon-rr'),194.67 data from dual union all
    17  select 15,to_date ('Mar-09', 'Mon-rr'),208.67 data from dual union all
    18  select 16,to_date ('Apr-09', 'Mon-rr'),222.67 data from dual
    19  )
    20  select id
    21       , mon
    22       , data
    23       , data - lag (data, 1, 0) over (partition by trunc (mon, 'yyyy')
    24                 order by mon)
    25    from test
    26   order by id
    27  ;
            ID MON               DATA DATA-LAG(DATA,1,0)OVER(PARTITI
             1 1-1-2010            10                             10
             2 1-2-2010            20                             10
             3 1-3-2010            30                             10
             4 1-4-2010            50                             20
             5 1-5-2010            60                             10
             6 1-6-2010            70                             10
             7 1-7-2010           100                             30
             8 1-8-2010           110                             10
             9 1-9-2010           120                             10
            10 1-10-2010          140                             20
            11 1-11-2010          150                             10
            12 1-12-2010          170                             20
            13 1-1-2009        180,67                         180,67
            14 1-2-2009        194,67                             14
            15 1-3-2009        208,67                             14
            16 1-4-2009        222,67                             14
    16 rows selected

  • Migrating from TSQL Need Help? printing multiple columns in Stored procedur

    I need to create a Stored Procedure which returns set of columns not all
    (for eg FirstName, LastName, Dept_Id) from emloyee table based on certain conditions.
    In TSQL, it is very simple to create such stored procedures which return full recordset(or subset).
    I tried creating explicit cursors but I can print only one record at a time. I dnt want concatenation of columns. I want seperate columns in ouput. How to achieve this.?
    Code : (But i can only concatenate and print results, what i want is diffrent columns)
    declare
    f_name employees.first_name%type;
    l_name employees.last_name%type;
    cursor c is
    select first_name,last_name
    from employees;
    begin
    open c;
    loop
    fetch c into f_name,l_name;
    exit when c%notfound;
    DBMS_OUTPUT.PUT_LINE (f_name||' '||l_name);
    end loop;
    close c;
    end;

    Another very informative article on ref cursors:
    PL/SQL 101 : Understanding Ref Cursors

  • Need help in GL table column mapping - R12.1.3

    Hi,
    we are upgrading from 11.5.10 to R12.1.3
    While modifying one of the reports, come across a query which uses gl_mc_reporting options table.
    This table is replaced by gl_ledger_relationships in R12.
    However, in the query, we are using reporting_set_of_books_id in the where clause.
    Can you please let me knw the corresponding column I need to use from gl_ledger_relationships in R12.
    Thanks!

    well vishwa u r right it wont work for multiple columns,
    then i guess this shud work.
    @thendral
    U can try like this create the rows with single column
    then print all ur text elements with spaces inserted manually between them with text editor then in conditions tab of the text elements specify ur condition according to what all u want to print.
    кu03B1ятu03B9к

  • SQL Help -- Need help with pivoting the columns to rows

    I have a requierement to split the columns into multiple rows. For example:
    EMP_DEPT
    rowid empid1 ename1 dept1 empid2 ename2 dep2 empid2 ename2      dep3 empid4 ename4 dept4
    100001 1 'SCOTT' 10 2 'DAVE' 20 3 'MILLER'     10 4 SMITH 20
    100002 1 'SCOTT' 10 2 'DAVE' 20 3 'MILLER'     20      
    Note: EMP_DEPT may not always have all the 4 employee info populated for example in row 2 only 3 employees info is there
    I need to convert it and insert into EMPLOYEE table as follows:
    EMPLOYEE
    empid ename dept
    1 SCOTT 10
    2 DAVE 20
    3 MILLER 10
    4 SMITH 20
    1 SCOTT 10
    2 DAVE 20
    3 MILLER 20
    Thanks
    Kev

    Frank Thank You for your response.
    I am on oracle 10gR2.
    Posting some sample DDL and data here as requested:
    CREATE TABLE EMP
      PK          NUMBER(10),
      EMP_NAME1   VARCHAR2(100 BYTE),
      EMP_ID1     NUMBER(10),
      EMP_NAME2   VARCHAR2(100 BYTE),
      EMP_ID2     NUMBER(10),
      DEPT_NAME1  VARCHAR2(200 BYTE),
      DEPT_ID1    NUMBER(10),
      DEPT_NAME2  VARCHAR2(200 BYTE),
      DEPT_ID2    NUMBER(10)
    CREATE TABLE EMP_DEPT
    ( PK NUMBER(10),
    ENTY_TYPE VARCHAR2(100),
    ENTY_NAME VARCHAR2(100),
    ENTY_ID NUMBER(10)
    Insert into EMP
       (PK, EMP_NAME1, EMP_ID1, EMP_NAME2, EMP_ID2, DEPT_NAME1, DEPT_ID1, DEPT_NAME2, DEPT_ID2)
    Values
       (1, 'SCOTT', 10001, 'FRANK', 10002,
        'MARKETING', 10, 'ACCOUNTING', 20);
    Insert into EMP
       (PK, EMP_NAME1, EMP_ID1, EMP_NAME2, EMP_ID2, DEPT_NAME1, DEPT_ID1)
    Values
       (2, 'SCOTT1', 10003, 'FRANK1', 10004,
        'MARKETING1', 30);
    COMMIT;
    SELECT
    FROM
    EMP;
    PK     EMP_NAME1     EMP_ID1     EMP_NAME2     EMP_ID2          DEPT_NAME1     DEPT_ID1     DEPT_NAME2     DEPT_ID2
    1     SCOTT          10001     FRANK          10002          MARKETING     10          ACCOUNTING     20
    2     SCOTT1          10003     FRANK1          10004          MARKETING1     30               My requirement is to:
    SELECT from emp and INSERT INTO EMP_DEPT so that columns are broken into rows as follows
    PK ENTY_TYPE, ENTY_NAME    ENTY_ID
    1  EMPLOYEE   SCOTT        10001
    2  EMPLOYEE   FRANK        10002
    3  DEPARTMENT MARKETING    10
    4  DEPARTMENT ACCOUNTING   20    
    5  EMPLOYEE   SCOTT1       10003
    6  EMPLOYEE   FRANK1       10004
    7  DEPARTMENT MARKETING1   30          Thanks
    Kevin
    Edited by: user10210466 on Dec 8, 2010 1:37 PM

Maybe you are looking for