How to Convert Rows of the Columns in Multiple Columns

Hi,
I have Data in one of the table of Oracle Application.
Sample Data.....
Period_Start_date Period_Type Demand
09-22-2005 1 5
09-21-2005 1 10
09-20-2005 1 5
09-19-2005 1 2
09-18-2005 1 20
09-17-2005 1 19
09-16-2005 1 3
Output Required.
Period 6 Period 5 Period 4 Period 3 Period 2 Period 1 Current
3 19 20 2 5 10 5
This need to be Done in Using SQL Statement.
On the base of Current Date enter by the User ...it will pickup last six date and Demand on that Date in Required Format.
Pls Do let me know Any more Clarification
Pls can any body Help me
Regards
Roshan

CREATE TABLE t1
( col1 VARCHAR2(10),
col2 VARCHAR2(100)
INSERT INTO t1 VALUES('A','123,456,789');
INSERT INTO t1 VALUES('B','012,345');
INSERT INTO t1 VALUES('C','678,901,234');
SELECT col1, col2, pos, pre, SUBSTR(col2, pre+1, pos-pre-1) token FROM (
SELECT row_num, col1, col2, decode(pos,0,LENGTH(col2)+1,pos) pos, pre FROM (
SELECT row_num, col1, col2, pos, nvl(LAG(pos) OVER (PARTITION BY col1 ORDER BY row_num),0) pre
FROM (
SELECT row_num, vw.col1, vw.col2, INSTR(vw.col2,',',1,row_num) pos
FROM (
SELECT ROWNUM row_num FROM (
SELECT LEVEL FROM dual connect by LEVEL <= 5
)) r,
(SELECT col1, col2 FROM t1) vw
WHERE pos <> 0 OR pre <> 0
i think some part it may be help u also

Similar Messages

  • How to convert row data into columns without using pivot table?

    Hello guys
    I have a report that has several columns about sales call type and call counts
    It looks like this:
    Calls Type Call Counts
    Missed 200
    Handled 3000000
    Rejected 40000
    Dropped 50000
    Now I wanna create a report that look like this:
    Missed call counts Handled Call counts Rejected Counts Drop counts Other Columns
    200 300000000 40000 50000 Data
    So that I can perform other calculations on the difference and comparison of handled calls counts vs other call counts..
    I know pivot table view can make the report look like in such way, but they cant do further calculations on that..
    So I need to create new solid columns that capture call counts based on call types..
    How would I be able to do that on Answers? I don't have access to the RPD, so is it possible to do it sololy on answers? Or should I just ask ETL support on this?
    Any pointers will be deeply appreciated!
    Thank you

    Thanks MMA
    I followed your guidance and I was able to create a few new columns of call missed count, call handled counts and call abandoned counts.. Then I create new columns of ave missed counts, ave handled counts and so forth..
    Then I went to the pivot view, I realized there is a small problem.. Basically the report still includes the column "call types" which has 3 different types of call "miss, abandon and handled". When I exclude this column in my report, the rest of the measures will return wrong values. When I include this column in the report, it shows duplicate values by 3 rows. It looks like this:
    Queue name Call types Call handled Call missed Call abondoned
    A Miss 8 10 15
    A Handled 8 10 15
    A Abandoned 8 10 15
    in pivot table view, if I move call type to column area, the resulted measures will become 8X3, 10X3 and 15X3
    So is there a way to eliminate duplicate rows or let the system know not to mulitply by 3?
    Or is this as far as presentation service can go in terms of this? Or should I advice to provide better data from the back end?
    Please let me know, thanks

  • How to convert Rows to different columns

    Hi All,
    I am having a table address with the following data.
    ID          REL_NAME     REL_RELATION  REL_PHONE
    1---          kish_rel1---     wife---     1111
    1---          kish_rel2---     sister---     2222
    1---          kish_rel3---     brother---     3333
    2---          ram_rel1---     brother---     4444
    Now i want to display rows data into columns. See the output i want. Exactly, I dont know how many rows are there for each ID. It may increase or decrease.
    ID          REL_NAME     REL_RELATION  REL_PHONE
    1---kish_rel1---     wife---     1111---kish_rel2---     sister---     2222---kish_rel3---     brother---     3333
    2---ram_rel1---     brother---     4444
    Thanks in advance,
    Pal

    Hi,
    I have found this is useful. But it is static. It wont work if we dont know the maximum number of rows present when grouped by ID.
    Is there any other solution, which will give correct values, if we dont know the row count when grouped by ID.
    SELECT hrid,
    MAX(case when seq=1 then rel_name end) AS "rel_name1",
    MAX(case when seq=1 then rel_relation end) AS "rel_relation1",
    MAX(case when seq=1 then rel_phone end) AS "rel_phone1",
    MAX(case when seq=2 then rel_name end) AS "rel_name2",
    MAX(case when seq=2 then rel_relation end) AS "rel_relation2",
    MAX(case when seq=2 then rel_phone end) AS "rel_phone2",
    MAX(case when seq=3 then rel_name end) AS "rel_name3",
    MAX(case when seq=3 then rel_relation end) AS "rel_relation3",
    MAX(case when seq=3 then rel_phone end) AS "rel_phone3",
    MAX(case when seq=4 then rel_name end) AS "rel_name4",
    MAX(case when seq=4 then rel_relation end) AS "rel_relation4",
    MAX(case when seq=4 then rel_phone end) AS "rel_phone4"
    FROM (SELECT hrid, rel_name, rel_relation, rel_phone, ROW_NUMBER() over(partition by hrid ORDER BY hrid) AS seq FROM address)
    GROUP BY hrid
    Thanks,
    Pal

  • How to convert rows into single columns in Oracle?

    I have table with data like shown below in Oracle database.
    P_COLUMN
    COLUMN_1
    COLUMN_2
    COLUMN_3
    COLUMN_ 4
    COLUMN_5
    COLUMN_6
    COLUMN_7
    COLUMN_8
    COLUMN_9
    COLUMN_10
    1
    A1
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    A10
    1
    B1
    B2
    B3
    B4
    B5
    B6
    B7
    B8
    B9
    B10
    1
    C1
    C2
    C3
    C4
    C5
    C6
    C7
    C8
    C9
    C10
    2
    AA1
    AA2
    AA3
    AA4
    AA5
    AA6
    AA7
    AA8
    AA9
    AA10
    2
    BB1
    BB2
    BB3
    BB4
    BB5
    BB6
    BB7
    BB8
    BB9
    BB10
    I need a query to get one row based on P_COLUMN's value i.e. for P_COLUMN =1, below should be output :-
    C_1
    C_2
    C_3
    C_4
    C_5
    C_6
    C_7
    C_8
    C_9
    C_10
    C_11
    C_12
    C_13
    C_14
    C_15
    C_16
    C_17
    C_18
    C_19
    C_20
    C_21
    C_22
    C_23
    C_24
    C_25
    C_26
    C_27
    C_ 28
    C_29
    C_30
    C_31
    1
    A1
    A2
    A3
    A4
    A5
    A6
    A7
    A8
    A9
    A10
    B1
    B2
    B3
    B4
    B5
    B6
    B7
    B8
    B9
    B10
    C1
    C2
    C3
    C4
    C5
    C6
    C7
    C8
    C9
    C10
    2
    AA1
    AA2
    AA3
    AA4
    AA5
    AA6
    AA7
    AA8
    AA9
    AA10
    BB1
    BB2
    BB3
    BB4
    BB5
    BB6
    BB7
    BB8
    BB9
    BB10
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    NULL
    i searched google and found PIVOT, CROSS JOIN etc but could not use those keyword properly.
    Thanks in advance.
    Note - My DB client version is 11g.

    Since you have 11G, here's an alternative with the PIVOT clause.
    First, set up test data with up to 10 rows:
    CREATE TABLE T(P1,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10) AS SELECT
    1,1,2,3,4,5,6,7,8,9,10 FROM DUAL;
    INSERT INTO T
    WITH DATA AS (SELECT LEVEL*10 N FROM DUAL CONNECT BY LEVEL <= 9)
    SELECT P1, C1+N, C2+N, C3+N, C4+N, C5+N, C6+N, C7+N, C8+N, C9+N, C10+N
    FROM T, DATA;
    INSERT INTO T
    SELECT P1+1,C1,C2,C3,C4,C5,C6,C7,C8,C9,C10
    FROM T
    WHERE C1 <= 11;
    select * from t order by p1,c1;
    P1
    C1
    C2
    C3
    C4
    C5
    C6
    C7
    C8
    C9
    C10
    1
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    1
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    1
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    1
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    1
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    1
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    1
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    1
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    1
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    1
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    2
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    2
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    Now the SELECT statement using PIVOT:
    SELECT * FROM (
      SELECT T.*,
      ROW_NUMBER() OVER (
        PARTITION BY P1
        ORDER BY C1,C2,C3,C4,C5,C6,C7,C8,C9,C10
      ) RN
      FROM T
    PIVOT(
      MAX(C1) C1, MAX(C2) C2, MAX(C3) C3, MAX(C4) C4, MAX(C5) C5,
      MAX(C6) C6, MAX(C7) C7, MAX(C8) C8, MAX(C9) C9, MAX(C10) C10
      FOR RN IN (1 R1,2 R2,3 R3,4 R4,5 R5,6 R6,7 R7,8 R8,9 R9,10 R10)
    P1
    R1_C1
    R1_C2
    R1_C3
    R1_C4
    R1_C5
    R1_C6
    R1_C7
    R1_C8
    R1_C9
    R1_C10
    R2_C1
    R2_C2
    R2_C3
    R2_C4
    R2_C5
    R2_C6
    R2_C7
    R2_C8
    R2_C9
    R2_C10
    R3_C1
    R3_C2
    R3_C3
    R3_C4
    R3_C5
    R3_C6
    R3_C7
    R3_C8
    R3_C9
    R3_C10
    R4_C1
    R4_C2
    R4_C3
    R4_C4
    R4_C5
    R4_C6
    R4_C7
    R4_C8
    R4_C9
    R4_C10
    R5_C1
    R5_C2
    R5_C3
    R5_C4
    R5_C5
    R5_C6
    R5_C7
    R5_C8
    R5_C9
    R5_C10
    R6_C1
    R6_C2
    R6_C3
    R6_C4
    R6_C5
    R6_C6
    R6_C7
    R6_C8
    R6_C9
    R6_C10
    R7_C1
    R7_C2
    R7_C3
    R7_C4
    R7_C5
    R7_C6
    R7_C7
    R7_C8
    R7_C9
    R7_C10
    R8_C1
    R8_C2
    R8_C3
    R8_C4
    R8_C5
    R8_C6
    R8_C7
    R8_C8
    R8_C9
    R8_C10
    R9_C1
    R9_C2
    R9_C3
    R9_C4
    R9_C5
    R9_C6
    R9_C7
    R9_C8
    R9_C9
    R9_C10
    R10_C1
    R10_C2
    R10_C3
    R10_C4
    R10_C5
    R10_C6
    R10_C7
    R10_C8
    R10_C9
    R10_C10
    1
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    2
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20

  • How to convert rows into columns with decode function

    Hi,
    How to convert rows into columns with the help of decode function in oracle.
    thanks and regards
    P Prakash

    say
    col1 col2
    1 10
    2 20
    3 30
    then use
    select col1,
    sum(decode(col2,10,10)) "new1"
    sum(decode(col2,20,20))"new2"
    sum(decode(col2,30,30))"new3"
    from table_name
    group by col1;
    we used sum u can use ny function if wont u have to give the column name i.e col2 name also
    so i think u got it nw
    regards

  • How to convert rows to columns in sql server 2008

    How to convert rows to columns in sql server 2008 using the GROUP BY function? (only one query allowed)

    Lookup the Pivot transformation. From BOL:
    The Pivot transformation makes a normalized data set into a less normalized
    but more compact version by pivoting the input data on a column value. For
    example, a normalized Orders data set that lists customer name, product, and quantity purchased typically has multiple rows for any customer who purchased multiple products, with each row for that customer showing order
    details for a different product. By pivoting the data set on the product column, the Pivot transformation can output a data set with a
    single row per customer. That single row lists all the purchases by the customer, with the product names shown as column names, and the quantity shown as a value in the product column. Because not every customer purchases every product, many columns may contain
    null values.
    When a dataset is pivoted, input columns perform different roles in the pivoting process. A column can participate in the following ways:
    The column is passed through unchanged to the output. Because many input rows
    can result only in one output row, the transformation copies only the first
    input value for the column.
    The column acts as the key or part of the key that identifies a set of
    records.
    The column defines the pivot. The values in this column are associated with
    columns in the pivoted dataset.
    The column contains values that are placed in the columns that the pivot
    creates.
    Paul

  • How to convert rows into column

    Hi,
    can any one help me how to convert rows into column by pl/sql procedure.
    Thanks and Regards

    http://www.oracle.com/technology/oramag/code/tips2004/050304.html
    -- dropping the sample table if exists
    drop table rowstocol
    -- create sample table
    create table rowstocol ( name varchar2(20));
    -- Inserting rows into sample table
    insert into rowstocol values('Amit Zhankar');
    insert into rowstocol values('Piyu Yawalkar');
    insert into rowstocol values('Piyu Yawalkar');
    insert into rowstocol values('Ashish Ghelani');
    insert into rowstocol values('Aditi Zhankar');
    insert into rowstocol values('Tom Kyte');
    insert into rowstocol values('Oracle');
    -- Following query should be run to create a sql. This result sql should be run to convert rows to column.
    -- The following query uses just the tablename (whose data is to be converted) and name of the column (which is to be converted).
    -- Example taken here is table rowstocol, column name.
    SELECT cc
    FROM (select decode(rn ,1 ,'Select ',null) ||' MAX (CASE WHEN dr = '|| rownum||' THEN DECODE (rn,1, col1) END) '||
    decode(rn,maxr,' col1 from ','||'||chr(39)||','||chr(39)||'|| ') cc,rn,maxr
    from (SELECT ROWNUM rn,count(0) over() maxr FROM rowstocol) order by rn) trows
    union all
    select '(SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn' cc from dual;
    -- The result of this query will do the reqd conversion from row to column.
    -- Replace table rowstocol by your table, column name by your column.
    CC
    Select MAX (CASE WHEN dr = 1 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 2 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 3 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 4 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 5 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 6 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 7 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 8 THEN DECODE (rn,1, col1) END) col1 from
    (SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn
    Select MAX (CASE WHEN dr = 1 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 2 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 3 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 4 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 5 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 6 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 7 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 8 THEN DECODE (rn,1, col1) END) col1 from
    (SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn;
    COL1
    Aditi Zhankar,Amit Zhankar,Ashish Ghelani,Oracle,Oracle,Piyu Yawalkar,Piyu Yawalkar,Tom Kyte
    Edited by: bhooma on Jan 20, 2009 2:44 AM

  • How to convert rows into columns

    Hi,
    How to convert rows into columns of two different tables.
    These two tables have two common columns namely (shipline,pos).
    Let me know if we have any built in functions to do this.
    thank you very much .
    Edited by: 808542 on Dec 7, 2010 8:35 PM
    Edited by: 808542 on Dec 7, 2010 8:37 PM

    Have you tried this first?
    http://forums.oracle.com/forums/search.jspa?threadID=&q=row+to+column&objID=f75&dateRange=last90days&userID=&numResults=15&rankBy=10001

  • How can I display all the columns on the screen without scrolling from side to side?

    My clinic software has many columns. How can I display all the columns without having to scroll from left to right all the time?

    If the software you are using doesn't offer the ability to increase or decrease document size, as many do, then the only way is to increase your screen resolution. If that's not possible, maybe you can decrease your font size?  If you can't do any of these, I think you're out of luck!

  • How to convert sysdate to the format dd-mon-yyyy

    how to convert sysdate to the format dd-mon-yyyy

    <how to convert sysdate to the format dd-mon-yyyy>
    This question is better answered by thinking about about how Oracle dates work. SYSDATE is a pseudocolumn (function without any arguments) that returns a date value: it already is a date. Oracle date values are stored not as we see them, say 'DD-MON-YY', but as a series of bytes with the different date components from the millennium down to the second. We NEVER see dates as they are stored but use the formats for automatic conversion.
    To display a date the way you want use TO_CHAR() with an edit mask or as others suggested change your NLS_DATE_FORMAT (thought I advise against this as most systems use DD-MON-YY and porting queries from other systems or even OTN can easily break). To change a converted string back to a date use TO_DATE() with an edit mask.

  • How to get row of the selected cell  in ALV  while implementing OVS

    Dear Folks,
                    I am implementing OVS search help in ALV.When i click on cell, i can see the search help in  cell and now i can identify the colomn of the cell but i can't identify the row of the cell.Can any one tell me how to identify row of the cell in this case.
    Nirad.

    Thnx for the answer nithya.I have solved problem my self.
    DATA: elem_ovs TYPE REF TO if_wd_context_element,
            ls_data TYPE REF TO data,
            ls_index type string.
      FIELD-SYMBOLS : <ovs_data> TYPE data.
      elem_ovs = ovs_callback_object->context_element.
      ls_data = elem_ovs->get_static_attributes_ref( ).
      ls_index = elem_ovs->GET_INDEX( ).
    and this is the solution.

  • How to Convert Rows to Column in Query

    Dear All,
    I'm having problems in converting the data from rows into columns. Eg:
    - item A sold on 01/01/07 = 5 kg
    - item A sold on 10/01/07 = 5 kg
    total item A sold in "JAN" = 10kg
    - item A sold on 01/03/07 = 20 kg
    total item A sold in "Mar" = 20kg
    I did a query and it appear as below (in which I need the period as column)
    Item Qty Period
    A 10 2007-01
    A 20 2007-03
    The output I need is :
    Item Jan Feb Mar
    A 10 - 20
    I've refer to the query posted in "Item History Query", even though I can get the column from Jan - Dec, but the total quantity for each month is not accurate. Please advise, and thanks for your time.
    Cheers,
    Serene

    Hello Serene,
    The Quantities will not be correct because you are using a Period Code in the Selection Criteria but it is not checked in the Select Statement. 
    But rewriting the code would cause duplicate entries for each item per months because of how the Group by clause works.
    CHECK THIS
    SELECT T1.ItemCode, T1.Dscription,
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 1 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'JAN',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 2 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'FEB',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 3 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'MAR',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 4 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'APR',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 5 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'MAY',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 6 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'JUN',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 7 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'JUL',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 8 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'AUG',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 9 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'SEP',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 10 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'OCT',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 11 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'NOV',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE MONTH(DOCDATE) = 12 AND ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'DEC',
    (SELECT SUM(QUANTITY) FROM INV1 WHERE ITEMCODE = T1.ItemCode AND DOCDATE >= T2.F_RefDate AND DOCDATE <= T_RefDate) AS 'TOTAL'
    FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OFPR T2 ON T0.FinncPriod = T2.AbsEntry
    WHERE T0.CardName ='[%A]' AND T2.Code >='[%1]' AND T2.Code <='[%2]'
    GROUP BY T1.ItemCode, T1.Dscription, T2.F_RefDate, T2.T_RefDate
    The Only way out of this is to declare Variable and Assign the F_RefDate and T_RefDate and then use the variables in the Select Statements.
    Suda

  • How to convert row into column

    Hi All,
    My oracle apps version is r12 and db is 10 and i am using Bi publisher version 10g.
    Is it possible to convert row into column in Rtf template,
    My Query is
    SELECT distinct pvs.vendor_site_code,sum(aia.invoice_amount)
    FROM ap_invoices_all aia, po_vendors po, po_vendor_sites_all pvs
    WHERE aia.org_id = pvs.org_id
    AND aia.vendor_id = po.vendor_id
    AND aia.vendor_site_id = pvs.vendor_site_id
    AND aia.org_id=204
    group by pvs.vendor_site_code
    And output is like this
    Vendor sitecode Invoiceamt
    EAM-ERS 79240
    STAR GATE - PAY 3245902.31
    UPS - HQ 10792040.9
    Like this
    So in template i need the output like this
    Vendor sitecode EAM-ERS STAR GATE - PAY UPS - HQ
    Invoiceamt 79240 3245902.31 10792040.9
    I tried to achieve the output using sql query but by hardcoding only i have achieved it, so i have tried to convert directly in RTF template.
    can any one tell me is it possible.
    And if new project is added from the front end ie(now the query will produce 4 rows but now in template i have created only three columns)
    Is it possible to add a new column dynamically.
    Can any one please guide me and tell me is there any example.
    Thanks & regards
    Srikkanth

    Take a look at this post: http://blogs.oracle.com/roller-ui/bsc/spider.jsp?entry=MT%3aENTRY%3a5001
    Thanks,
    Bipuser

  • How to convert rows to columns of a table?

    I want to convert rows to columns of a table..
    Query in SQL??

    965373 wrote:
    I want to convert rows to columns of a table..
    Query in SQL??PIVOT by Frank Help for a query to add columns
    PIVOT by TomK http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:766825833740

  • How to add rows in the multicolumn listbox

    hello all,
    the questions are as below:
    1. how to add the rows in the multicolumn listbox?
    2. the message is RS232 communication message with hex format, how to convert the 2D format to adapt the itemnames property?
    does anyboady can provide a simple example? thanks a lot.
    Solved!
    Go to Solution.

    Hello muks,
    I would like to come up with the function like below picture:
    the multicolumn listbox include 5 columns, the fifth column is hex format. I want to add the row one by one after each cycle, meanwhile there's a button that can clear the contents in the multicolumn listbox.
    So the challenge for me is how to concatenate the different format into one array. then how to insert the row one by one.
    Thanks in advance.

Maybe you are looking for