Transform columns into rows

I have a requirement in which I need to write a query to convert the columns to the lines.

Entry table (DB - 11 g)
========
ORDER_ID HOME_NUM WORK_NUM MOBILE_NUM FAX_NUM
100 999456901 < null > 334054483 < null >
101 < null > < null > < null > 787372163
102 587372163 943528985 642344352 677676666
103 53522890 < null > < null > < null >
104 < null > 956656655 < null > 83366656

decode the numbers like that, HOME_NUM = 1, WORK_NUM = 2, MOBILE_NUM = 3 and FAX_NUM = 4 and insert as phone_type_cd with the corresponding number. Output must be

ORDER_ID phone_type_cd contact_num
100 1 999456901
100 3 334054483
787372163 4 101
102 1 587372163
2 102 943528985
102 3 642344352
677676666 4 102
103 1 53522890
2 104 83366656
104 3 956656655

Published by: manon July 12, 2011 06:09
with t as (
           select 100 order_id,999456901 home_num,334054483 work_num,null mobile_num,null fax_num from dual union all
           select 101,787372163,null,null,null from dual union all
           select 102,587372163,943528985,642344352,677676666 from dual union all
           select 103,53522890,null,null,null from dual union all
           select 104,83366656,956656655,null,null from dual
          )
-- end of on-the-fly data sample
 select order_id,
        1 phone_type_cd,
        home_num contact_num
   from  t
   where home_num is not null
union all
 select order_id,
        2 phone_type_cd,
        work_num contact_num
   from  t
   where work_num is not null
union all
 select order_id,
        3 phone_type_cd,
        mobile_num contact_num
   from  t
   where mobile_num is not null
union all
 select order_id,
        4 phone_type_cd,
        fax_num contact_num
   from  t
   where fax_num is not null
order by order_id,
         phone_type_cd
/

  ORDER_ID PHONE_TYPE_CD CONTACT_NUM
---------- ------------- -----------
       100             1   999456901
       100             2   334054483
       101             1   787372163
       102             1   587372163
       102             2   943528985
       102             3   642344352
       102             4   677676666
       103             1    53522890
       104             1    83366656
       104             2   956656655

10 rows selected.

SQL>  

SY.

Published by: Solomon Yakobson, July 12, 2011 09:14

Tags: Database

Similar Questions

  • I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows?

    I tried to download a pdf and convert them into excel, but the data in excellent is always to the image format.  How can I get the pdf data into the columns and rows so that I can do the calculations?

    If you start the https://forums.adobe.com/welcome Forums Index

    You will be able to select a forum for the specific Adobe products you use

    Click on the symbol "arrow down" on the right (where it is said to see all our products and Services) to open the drop-down list and scroll

  • concatenate the strings from a column into a single row?

    How to concatenate strings from a column into a single line?

    Color
    ------
    Red
    Orange
    Blue
    Green

    And return a set of results as follows:

    Colors
    -------------------------
    Red, orange, blue, green

    Various ways can be found here:
    http://www.Oracle-base.com/articles/10G/StringAggregationTechniques.php

  • Convert a single column into multiple lines

    Hi people,

    I have a task to display a single column into multiple lines (for use in LOV)

    For Ex:

    The column consistes of value such as 98,78,67,68,34,90. -It's a unique column values where none of the values can be ' number that is separated by commas

    Then we must view it as

    98
    78
    67
    68
    34
    90
    -under the number of lines (no lines can be ' do not number).

    Thanks in advance

    Try this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select regexp_substr('98,78,67,68,34,90', '[^,]+',1,level) Value
      2    from dual
      3*   connect by level <= regexp_count('98,78,67,68,34,90',',') + 1
    SQL> /
    
    VALUE
    -----------------
    98
    78
    67
    68
    34
    90
    
    6 rows selected.
    

    Thank you!

  • SQL help - Need help to rotate the columns to rows

    I have a HughesNet to divide the columns into multiple lines. For example:

    EMP_DEPT

    ROWID empid1 ename1 empid2 ename2 empid2 ename2 empid4 ename4 dept4 dep3 dep2 dept1
    100001 1 'SCOTT' 10 2 'DAVE' 20 3 10 4 20 SMITH "MILLER"
    100002 1 'SCOTT' 10 2 'DAVE' 20 3 'MILLER' 20

    Note: EMP_DEPT do not always have information about the 4 employees settled for example in info only 3 employees rank 2 are there

    I need to convert and insert it into the EMPLOYEE table as follows:

    EMPLOYEE

    EmpID ename dept
    1 SCOTT 10
    2 20 DAVE
    3 MILLER 10
    4 SMITH 20

    1 SCOTT 10
    2 20 DAVE
    3 MILLER 20

    Thank you
    KeV

    Hey Kevin,

    Here's one way:

    WITH t AS (
      SELECT level i FROM dual CONNECT BY level <= 4
    )
    SELECT enty_type, enty_name, enty_id
    FROM (
      SELECT case when mod(t.i,2) = 0 then 'DEPARTMENT'
                  else 'EMPLOYEE'
             end as enty_type
           , case t.i
               when 1 then emp_name1
               when 2 then dept_name1
               when 3 then emp_name2
               when 4 then dept_name2
             end as enty_name
           , case t.i
               when 1 then emp_id1
               when 2 then dept_id1
               when 3 then emp_id2
               when 4 then dept_id2
             end as enty_id
      FROM emp
           CROSS JOIN t
    )
    WHERE enty_id IS NOT NULL
    ;
    

    Another using the MODEL clause:

    SELECT *
    FROM (
      SELECT enty_id, enty_name, enty_type
      FROM emp
      MODEL
      RETURN UPDATED ROWS
      PARTITION BY (pk)
      DIMENSION BY (0 i)
      MEASURES(
         emp_id1, emp_name1
       , emp_id2, emp_name2
       , dept_id1, dept_name1
       , dept_id2, dept_name2
       , cast(null as number(10)) enty_id
       , cast(null as varchar2(200)) enty_name
       , cast(null as varchar2(30)) enty_type
      )
      RULES (
         enty_type[1] = 'EMPLOYEE' , enty_id[1] = emp_id1[0], enty_name[1] = emp_name1[0]
       , enty_type[2] = 'EMPLOYEE' , enty_id[2] = emp_id2[0], enty_name[2] = emp_name2[0]
       , enty_type[3] = 'DEPARTMENT' , enty_id[3] = dept_id1[0], enty_name[3] = dept_name1[0]
       , enty_type[4] = 'DEPARTMENT' , enty_id[4] = dept_id2[0], enty_name[4] = dept_name2[0]
      )
    )
    WHERE enty_id IS NOT NULL
    ;
    

    Published by: odie_63 on 8 Dec. 2010 21:00

  • can I write in a clay column and row in excel?

    Hello!!!

    Well, is - can anyone help me and tell me, if I can write something of labview in a clay column and row in excel?

    excellent couerse in a clay column and row to an existing file...

    CAN SOMEONE HELP ME OR SAY SOMETHING PLEASE?

    Ago, as Sophia said, you can do this using ActiveX, but that requires a lot of programming

    but you can learn a lot

  • How to save the table column and row headings

    I have a table where I activated the column and row headings.  Once the table is loaded with data, I would like to save the contents of the table, including the column and row headings in a text file.  The crux of "value" property returns only the content of the table, not the row and column headers.  I could use "header line chains []" and '[] column header chains' property nodes as well, but I'm in the island there is an easier way.  Looks like adding the headers of lines would be difficult.  Any ideas?

    Thanks in advance.

    Here is a way. The construction with the empty constant is to provide to the left corner of the table where there is no data.

  • Remove the separator of columns and rows in spark DataGrid

    Capture.PNG

    Hello

    try searching a bit on the web with no success - how can I remove / handful of visibility of the separators of columns and rows in the DataGrid to spark flex 4.5

    See photo with separators:

    Two ways:

    (1) write a simple custom following appearance (the empty rectangles will cause the separators to disappear):

    
    
    
        
    
            
                
            
    
            
                
            
    
        
    
    
    

    (2) make a copy of the default Datagridskin and remove parts of skin 'columnSeparator' and 'rowSeparator.

    -Kevin

  • Column and row of transformation

    If I have a table with two columns, let's call them 'name' and 'value ':

    VALUE NAME

    ABC 1.11
    ABC 2.33
    ABC 3.44
    ABC 1.22
    ... ...
    ... ...

    DEF 3.66
    DEF 2.22
    DEF 9.99
    ...
    IGS 7.77
    IGS 3.44
    IGS 1.34
    IGS 1.22

    --------------------------------------------------------------------------------------------------

    Is it possible to convert this table data in the following format:

    ABC DEF GHI
    1.11 3.66 7.77
    2.33 2.22 3.44
    3.44...

    ?

    with an execution plan, it's good.

    If I do something like this:

    Select a.value as 'ABC', b.value form 'DEF '... DE)
    Select x.data in the x the_table where x.name = 'ABC'),
    Select x.data from the x the_table where x.name = 'DEF') b
    ...
    ...

    I have an execution plan that is just crazy. So I need some help on this issue.

    And if you're on 11g, pivot solution:

    select  ABC,
            DEF,
            GHI
      from  t
        pivot (
               sum(variable_data)
               for variable_name in (
                                     'ABC' as ABC,
                                     'DEF' as DEF,
                                     'GHI' as GHI
                                    )
              )
    /
    
           ABC        DEF        GHI
    ---------- ---------- ----------
            .5         .7         .7
            .6        .88         .8
            .7        2.3        2.3
    
    SQL> 
    

    SY.

  • Transform data in rows in column

    I don't know if the subject of this discussion justifies the question here! My question is:

    The result of my query looks like this:

    class_id total_employees identifiant_composant

    12                    1                  670

    12                    2                  1104

    11                    1                  131

    11                    2                  316

    13                    2                  5

    15                    1                  10

    The following query on the result above should make the output looks like this:

    id_comp total_employees_in_class_id_1 total_employees_in_class_id_2

    12                 670                                                 1104

    11                 131                                                 316

    13                 0                                                     5

    15                 10                                                   0

    I tried using lead and lag, but I can't get identifiant_composant where either missing class_id 1 or 2 as identifiant_composant = 13 or 15.

    Hello

    Here's one way:

    SELECT id_comp

    , NVL (total_1, 0) AS total_employees_in_class_id_1

    , NVL (total_2, 0) AS total_employees_in_class_id_2

    FROM MyTable

    PIVOT)

    SUM (total_employees)

    FOR class_id (1 AS total_1

    2 UNDER total_2

    )

    )

    ORDER BY id_comp

    ;

    You could do this with ADVANCE or a DELAY.  You could do an outer join partitioned on a table (or subquery) with 2 lines, to ensure that the results (before calling ADVANCE or a DELAY) always had 2 lines by identifiant_composant, but I can't see any advantage to doing it this way,

  • How to join two tables if you transpose the rows, columns and rows in one of the table

    Hi guys,.

    can someone help me please in the write request

    I have two tables

    Agents and Agent phones but in the agent phones table for the id of an agent it displays 4 rows because one of the column there types of different phones (office, mobile, home, fax)

    So instead of display 4 rows, I used max(case...) to convert rows to columns

    now how to reach it with another table

    Requirement:

    Database: 11.2.0.2.0

    create the table AGENT_PHONE

    (

    agent_id NUMBER (20) not null,

    agent_type_code VARCHAR2 (10) not null,

    agent_type_prefix VARCHAR2 (10) not null,

    Phone_Number VARCHAR2 (16) not null,

    phone_type_code VARCHAR2 (10) not null

    )

    CREATE TABLEAGENTS

    (

    agent_id NUMBER (20) not null,

    agent_type_code VARCHAR2 (10) not null,

    agent_type_prefix VARCHAR2 (10) not null,

    NAME VARCHAR2 (40) NOT NULL

    )

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '4805551436', 'CELL');

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '1111111111', 'PHONE');

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '2223334444',' OFF');

    INSERT INTO AGENT_PHONE(AGENT_ID,AGENT_TYPE_CODE,AGENT_TYPE_PREFIX,PHONE_NUMBER,PHONE_TYPE_CODE)

    VALUES (29709, ARE ', 'OFFICE', '5556667788', 'FAX');

    INSERT INTO VALUES AGENTS

    (29709, ARE ', 'OFFICE', 'FLY');

    INSERT INTO VALUES AGENTS

    (1234, ARE ', 'OFFICE', 'MIKE');

    SELECT * FROM AGENT_PHONES

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXPHONE_NUMBERPHONE_TYPE_CODE

    ---------------------------------------------------------------------------------------------

    29709REOFFICE4805551436CELL
    29709REOFFICE1111111111PHONE
    29709REOFFICE2223334444OFF
    29709REOFFICE5556667788

    FAX

    SELECT * AGENTS

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIX

    NAME

    29709REOFFICEROB
    1234REOFFICE

    MIKE

    This is so the data we have in both table

    Now, I transposed rows to columns in the table of agent phones so I used the following query

    SELECT AP. AGENT_ID,. AGENT_TYPE_CODE,. AGENT_TYPE_PREFIX.

    MAX (CASE WHEN AP. PHONE_TYPE_CODE = 'CELL' THEN AP. PHONE_NUMBER END) AS CELL.

    MAX (CASE WHEN AP. PHONE_TYPE_CODE = 'OFF' THEN AP PHONE_NUMBER END) AS TURNED OFF.

    MAX (CASE WHEN AP. PHONE_TYPE_CODE = 'FAX' THEN AP. PHONE_NUMBER END) LIKE FAX,.

    MAX (CASE WHEN PHONE_TYPE_CODE = 'PHONE'. THEN AP PHONE_NUMBER END) AS PHONE

    AGENT_PHONE AP

    WHERE AP. AGENT_ID = 29709

    GROUP OF AP. AGENT_ID, AP. AGENT_TYPE_CODE, AP. AGENT_TYPE_PREFIX.

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXCELLOFFFAXPHONE
    129709REOFFICE4805551436222333444455566677881111111111

    My question is how this to join the agents table so that my output should be like this...

    I want to display all the results in the table of the Agent, even if they are not in the table of agent phones. As you can see there are other agent id 1234 is also populated

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXNAMEAGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXCELLPHONEOFFFAX

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    29709REOFFICEROB29709REOFFICE4805551436111111111122233344445556667788
    1234REOFFICEMIKE

    Currently, I run this query and I get the output as below

    SELECT *.

    AGENTS HAS

    LEFT OUTER JOIN AGENT_PHONE AP

    ON A.AGENT_ID = AP. AGENT_ID

    AND A.AGENT_TYPE_CODE = AGENT_TYPE_CODE.

    AND A.AGENT_TYPE_PREFIX = AGENT_TYPE_PREFIX.

    AGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXNAMEAGENT_IDAGENT_TYPE_CODEAGENT_TYPE_PREFIXPHONE_NUMBERPHONE_TYPE_CODE
    129709REOFFICEROB29709REOFFICE4805551436CELL
    229709REOFFICEROB29709REOFFICE1111111111PHONE
    329709REOFFICEROB29709REOFFICE2223334444OFF
    429709REOFFICEROB29709REOFFICE5556667788FAX
    51234REOFFICEMIKE

    I want id 29709 agent in a line with 1234 agent also id to display

    You can rotate your phone number of agent in columns

    Select *.

    of AGENT_PHONE

    pivot)

    min (PHONE_NUMBER)

    for PHONE_TYPE_CODE in ('CELL' as a 'CELL', 'PHONE' like 'PHONE', 'OFF' in the 'OFF', 'FAX' as 'FAX')

    )

    AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX CELL PHONE OFF FAX
    29709 RE OFFICE 4805551436 1111111111 2223334444 5556667788

    Then you can join to view inline or CTE

    with AGENT_PHONE_PIVOT like)

    Select *.

    of AGENT_PHONE

    pivot)

    min (PHONE_NUMBER)

    for PHONE_TYPE_CODE in ('CELL' as a 'CELL', 'PHONE' like 'PHONE', 'OFF' in the 'OFF', 'FAX' as 'FAX')

    )

    )

    SELECT *.

    AGENTS HAS

    LEFT OUTER JOIN AGENT_PHONE_PIVOT AP

    ON A.AGENT_ID = AP. AGENT_ID

    AND A.AGENT_TYPE_CODE = AGENT_TYPE_CODE.

    AND A.AGENT_TYPE_PREFIX = AGENT_TYPE_PREFIX.

    AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX NAME AGENT_ID AGENT_TYPE_CODE AGENT_TYPE_PREFIX CELL PHONE OFF FAX
    29709 RE OFFICE ROB 29709 RE OFFICE 4805551436 1111111111 2223334444 5556667788
    1234 RE OFFICE MIKE - - - - - - -

    Is that what you're looking for?

  • Divide the values of a single column into multiple values of columns

    I want that the values of the "col_val" column to divide into several values in the column

    Table1:

    Col_val Col1, Col2

    Code1 POINT 45

    L2 AB 45

    L1 POINT 45 OF

    Code2 CAB 61

    ABC 51 LABORATORY

    SSS LAB 45

    QQQ BED 123

    BBV COT 100

    FFF COT 444

    Output as expected:

    OUT1 out2 out3-out4, out5

    Code1 AB SSS

    L1

    Code2

    ABC

    QQQ

    BBV

    FFF

    Each line must contain the values corresponding to the Col2 values and each column must have the values in Col1, as illustrated above.

    SQL> with t
      2  as
      3  (
      4  select 'Code1' col_val, 'ITEM' col1, 45 col2
      5    from dual
      6  union all
      7  select 'L2' col_val, 'AB' col1, 45 col2
      8    from dual
      9  union all
     10  select 'L1' col_val, 'ITEM' col1, 45 col2
     11    from dual
     12  union all
     13  select 'Code2' col_val, 'CAB' col1, 61 col2
     14    from dual
     15  union all
     16  select 'ABC' col_val, 'LAB' col1, 51 col2
     17    from dual
     18  union all
     19  select 'SSS' col_val, 'LAB' col1, 45 col2
     20    from dual
     21  union all
     22  select 'QQQ' col_val, 'COT' col1, 123 col2
     23    from dual
     24  union all
     25  select 'BBV' col_val, 'COT' col1, 100 col2
     26    from dual
     27  union all
     28  select 'FFF' col_val, 'COT' col1, 444 col2
     29    from dual
     30  )
     31  select max(col1)
     32       , max(col2)
     33       , max(col3)
     34       , max(col4)
     35       , max(col5)
     36    from (
     37            select decode(col1, 'ITEM', col_val) col1
     38                 , decode(col1, 'AB'  , col_val) col2
     39                 , decode(col1, 'LAB' , col_val) col3
     40                 , decode(col1, 'CAB' , col_val) col4
     41                 , decode(col1, 'COT' , col_val) col5
     42                 , t.col2 col_2
     43                 , row_number() over(partition by col2, col1 order by 1) rno
     44              from t
     45         )
     46   group
     47      by col_2, rno
     48   order
     49      by col_2;
    
    MAX(C MAX(C MAX(C MAX(C MAX(C
    ----- ----- ----- ----- -----
    Code1 L2    SSS
    L1
                ABC
                      Code2
                            BBV
                            QQQ
                            FFF
    
    7 rows selected.
    
    SQL>
    
  • Columns and rows of data have disappeared to chart

    Hello-

    I don't know what happened, but the rows/cells disappeared to my data in a bar graph in Illustrator CS5.5.

    The first number indicates upward, so I have to keep hitting tab, but they are not divided into visible cells longer.  Please see the image below.  I often see rows and columns in Excel.  Any help is greatly appreciated!

    Screen Shot 2013-05-20 at 3.26.38 PM.png

    That's what it should look like:

    Screen Shot 2013-05-20 at 4.24.22 PM.png

    What to say when you select the chart and find in appearance.

    If your don't have a transparenacy flatten on your chart then it seems group, rasterize would say image and you can no longer change the chart because the chart is more dynamic.

    Could possibly have CS6 file open in CS5. You graphics I bleive dissociated bevoems then, at least in the basic test I did.

  • 10g TRANSPOSE a single ROW/columns in ROWS/columns

    Hello
    I have a query that returns a single row with 4 columns

    I need output in a single line by column

    Here is a table of test;
    CREATE TABLE TEST
    (
    SEQ VARCHAR2(10),
    FT DATE,
    CD DATE,
    DELTA NUMBER(10)
    );
    INSERT INTO TEST (SEQ, FT, CD, DELTA) VALUES ('1111',SYSDATE-1,SYSDATE,1);
    
    SET NUM 999;
    
    SELECT SEQ, FT, CD, DELTA FROM TEST;
    
    DROP TABLE TEST;
    the output current is;
    SEQ        FT                        CD                        DELTA                  
    ---------- ------------------------- ------------------------- ---------------------- 
    1111       09-AUG-10                 10-AUG-10                 1                      
    and want;
    SEQ       1111
    FT        09-AUG-10
    CD        10-AUG-10
    DELTA     1
    SQL> ed
    Wrote file afiedt.buf
    
      1   select regexp_substr(str,'[^,]+',1,level)
      2   from
      3   (
      4   SELECT SEQ||','|| FT||','||CD||','||DELTA  str FROM TEST25
      5   )
      6*  connect by level <= length(str) - length(replace(str,','))+1
    SQL> /
    
    REGEXP_SUBSTR(STR,'[^,]+',1,LEVEL)
    -----------------------------------------------------------------------
    1111
    09-AUG-10
    10-AUG-10
    1
    
  • SQL to convert a row with 4 columns, 4 rows by 4 columns

    With the help of Frank Kulash yesterday (https://community.oracle.com/thread/3810284)

    I can now use UNPIVOT start with this:

    with tbl_data AS  
     (select 'N' argument1, 'Y' argument2, NULL argument3, 'Y' argument4 from dual)  
    select * from tbl_data;  
    
    
    ARGUMENT1 ARGUMENT2 ARGUMENT3 ARGUMENT4  
    --------- --------- --------- ---------  
    N         Y                   Y   
    

    And eventually conversion of a single line of output to 4 rows and 2 columns via:

    with tbl_data AS
     (select 'N' argument1, 'Y' argument2, NULL argument3, 'Y' argument4 from dual)
        SELECT  *
        FROM    tbl_data
        UNPIVOT INCLUDE NULLS
                (    col_heading
                FOR  col_name  IN ( argument1
                                  , argument2
                                  , argument3
                                  , argument4
                                  )
                );
    
        COL_NAME  COL_HEADING
        --------- -----------
        ARGUMENT1 N
        ARGUMENT2 Y
        ARGUMENT3
        ARGUMENT4 Y
    

    I was wondering if there are sort of Frank solution can be modified to include the 2 columns (for example, COL_SEQ and COL_PROMPT) with them, hard coded values for example, '1' for the SEQ and 'TEST' for the GUEST, as I have the solution to a Frank's UNION with another query that returns the 4 columns.

    i.e. the performance:

    COL_NAME  COL_HEADING COL_SEQ     COL_PROMPT
    --------- ----------- ----------- -----------
    ARGUMENT1 N           1           TEST
    ARGUMENT2 Y           1           TEST
    ARGUMENT3             1           TEST
    ARGUMENT4 Y           1           TEST
    

    Thank you

    Hello

    969483 wrote:

    With the help of Frank Kulash yesterday (https://community.oracle.com/thread/3810284)

    I can now use UNPIVOT start with this:

    1. with tbl_data AS
    2. (select "n" argument1, argument2 'Y', NULL argument3, 'Y' double argument4)
    3. Select * from tbl_data;
    4. ARGUMENT1 ARGUMENT2, ARGUMENT3 ARGUMENT4
    5. --------- --------- --------- ---------
    6. N         Y                   Y

    And eventually conversion of a single line of output to 4 rows and 2 columns via:

    1. with tbl_data AS
    2. (select "n" argument1, argument2 'Y', NULL argument3, 'Y' double argument4)
    3. SELECT *.
    4. OF tbl_data
    5. MUST INCLUDE NULL VALUES
    6. (col_heading
    7. FOR column-name IN (argument1
    8. argument2
    9. argument3
    10. argument4
    11. )
    12. );
    13. COLUMN COL_HEADING
    14. --------- -----------
    15. ARGUMENT1 N
    16. ARGUMENT2 Y
    17. ARGUMENT3
    18. ARGUMENT4 Y

    I was wondering if there are sort of Frank solution can be modified to include the 2 columns (for example, COL_SEQ and COL_PROMPT) with them, hard coded values for example, '1' for the SEQ and 'TEST' for the GUEST, as I have the solution to a Frank's UNION with another query that returns the 4 columns.

    i.e. the performance:

    1. COLUMN COL_HEADING COL_SEQ COL_PROMPT
    2. --------- ----------- ----------- -----------
    3. ARGUMENT1 N 1 TEST
    4. ARGUMENT2 Y 1 TEST
    5. ARGUMENT3 1 TEST
    6. ARGUMENT4 Y 1 TEST

    Thank you

    Of course, you can include constants hardcoded in any set of results; just put constants in the SELECT clause and assign aliases for columns.

    Don't forget, I havef you need anything in the more SELECT clause *, then * must be qualified with a table name or alias, so that in this case, you can do something like:

    SELECT d. *.

    1 AS col_seq

    'TEST' AS col_prompt

    OF tbl_data

    MUST INCLUDE NULL VALUES

    (col_heading

    FOR column-name IN (argument1

    argument2

    argument3

    argument4

    )

    d

    ;

Maybe you are looking for