Rows to column in 11g

I would like to convert the below rows into 8 column values. ie this query should always return 8 columns like desc_line1, desc_line2,
desc_line3 etc..... desc_line8
select * from
    select desc_line from
              select transaction_id, line_no, DESC_LINE,
                     row_number() OVER (PARTITION BY transaction_id order by line_no asc) as rn
                     from TB_SISADMIN_TRADE_DESCR
              where transaction_id = 7566
              ) a
    union all
    select null as desc_line from dual
    union all
    select null as desc_line from dual
    union all
    select null as desc_line from dual
    union all
    select null as desc_line from dual
    union all
    select null as desc_line from dual
    union all
    select null as desc_line from dual
    union all
    select null as desc_line from dual
where rownum <=8
DUE 08/15/2011 05.000% FA   15
OLTS 12/11/01 00012          
REV REPO RATE VARIABLE       
ON 12/11/01 OFF 12/12/01     
AS OF 12/11/01               
YIELD    4.868 % TO MATURITY 
UNITED STATES TREAS NTS      
                                          -----------> Null row here as 8th row

Great, but this is different than what i am looking for. bit tricky. Here is an eg below.
SQL> select * from test;
        NO NA
        10 x
        10 A
        10 M
        20 B
        20 Y
        20 A
        70 B
The query should first convert 8 rows always for each no (append null for name column is there is no records
                                                                                to make it a complete 8 record set)
        NO NA
        10 x
        10 A
        10 M
        10
        10
        10
        10
        10
        20 B
        20 Y
        20 A
        20  
        20  
        20  
        20  
        20  
        70 B
then, need to convert this 8 rows for each no into 8 columns..
No   Name1 Name2  Name3  Name4  Name5  Name6 Name7  Name8
10     X         X          M          null        null       null     null        null
20     B         Y          A          null        null       null    null        null
70     B        null         null       null        null       null    null        null

Similar Messages

  • Rows to column in 11g as single query

    I would like to create single row with column name
    as ISIN, CUSIP, SEDOL for each row which has desc IS, CU, SE
    as below
    SQL> select * from test;
          CODE DESCR                     VALUE
            10 IS                          100
            10 CU                          200
            10 SE                          200
            20 IS                          100
            20 CU                          200
            20 SE                          200
    The row should looks like below with column name ISIN, CUSIP, SEDOL
          CODE ISIN    CUSIP   SEDOL
            10 100     200      200
            20 100     200      200
    CREATE TABLE TEST
      CODE   NUMBER(10),
      DESCR  VARCHAR2(20 BYTE),
      VALUE  NUMBER(10)
    SET DEFINE OFF;
    Insert into TEST
       (CODE, DESCR, VALUE)
    Values
       (10, 'IS', 100);
    Insert into TEST
       (CODE, DESCR, VALUE)
    Values
       (10, 'CU', 200);
    Insert into TEST
       (CODE, DESCR, VALUE)
    Values
       (10, 'SE', 200);
    Insert into TEST
       (CODE, DESCR, VALUE)
    Values
       (20, 'IS', 100);
    Insert into TEST
       (CODE, DESCR, VALUE)
    Values
       (20, 'CU', 200);
    Insert into TEST
       (CODE, DESCR, VALUE)
    Values
       (20, 'SE', 200);
    COMMIT;

    Frank, the query i posted is an eg.
    in real i have 200k records in the table.
    SQL> explain plan for select * from master_base a, (SELECT  * FROM    id_xref
      2  PIVOT    (  max (SECURITY_XREF_NBR)
      3      FOR    SECURITY_XREF_CD
      4      IN    (    'IS'    AS isin
      5          ,    'CU'    AS cusip
      6          ,    'SD'    AS sedol
      7          )
      8      )
      9  ) b
    10  where a.security_nbr = b.security_nbr(+)
    11  ;
    Explained.
    Elapsed: 00:00:00.23
    SQL> set lines 200
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 2437398092
    | Id  | Operation             | Name                    | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |                         |   238K|    57M|       |  7495   (2)| 00:01:30 |
    |*  1 |  HASH JOIN OUTER      |                         |   238K|    57M|  8024K|  7495   (2)| 00:01:30 |
    |   2 |   TABLE ACCESS FULL   |          MASTER_BASE | 61776 |  7299K|       |   825   (3)| 00:00:10 |
    |   3 |   VIEW                |                         |   238K|    29M|       |  4647   (2)| 00:00:56 |
    |   4 |    HASH GROUP BY PIVOT|                         |   238K|    15M|    21M|  4647   (2)| 00:00:56 |
    |   5 |     TABLE ACCESS FULL |     ID_XREF     |   238K|    15M|       |   706   (4)| 00:00:09 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       1 - access("A"."sECURITY_NBR"="B"."SECURITY_NBR"(+))
    17 rows selected.Edited by: user520824 on Jul 22, 2010 8:28 AM
    Edited by: user520824 on Jul 22, 2010 8:31 AM

  • Pivot Table Row and Column extension OBIEE 11g

    Hi,
    I have pivot view report, I have 3 columns,
    1) User Name
    2) Date
    3) Login Count
    User Name will be row(Vertical)
    Date will be Column heading (Horizontal)
    Login Count Measures
    So I will get login Count of user wrt date.
    Now When I give Wide range of filter i.e, from 1st Jan 2010 to 31st Dec 2010.
    There is increase in row also column, when it reaches certain extent it gives error as *'Exceeded configured maximum number of allowed input records.'*
    How to change the limit? or there is any fix?
    Thanks,
    Satheesh

    Hi,
    I have also faced the same issue, i have solved by changing DefaultRowsDisplayed count in instance config file.
    <Views>
    <pivot table>
    <DefaultRowsDisplayed>75</DefaultRowsDisplayed>
    <pivot table>
    </Views>
    Paste that code (which i mentioned in my last post) in instanceconfig.xml before these tags
    </ServerInstance>
    </WebConfig>
    But remember you need to restart the presentation service once this is done....
    Thanks
    Deva

  • Converting from rows to columns

    Converting Rows to Columns
    We have one business requirment where they want to convert rows to columns. The data we are talking about is 2-3 TB of data. Data looks something in this format.
    Table Structure
    Date_1 Unit_Number Data_ID Data_Value
    2013-01-02 00:00:00 100013 123 671
    2013-01-02 00:00:00 100014 131 771
    2013-01-02 00:00:00 100015 281 812
    2013-01-02 00:00:00 100016 712 979
    2013-01-02 00:00:00 100017 715 719
    Pivoted table
    Date_1 RY XY HJ KD IK GH HH KK TK RT ...
    2013-01-02 00:00:00 671 771 812 979 719 979 719 980 799 79
    2013-01-02 00:10:00 671 771 812 979 719 979 719 980 799 79
    and so on
    We are pivoting this data using query and creating view using query something like below
    select a.date_1 date_1 a.unit_number system_number,
    max(CASE WHEN a.data_id= 123 then a.DATA_Value END) RY,
    max(CASE WHEN a.data_id= 281 then a.DATA_Value END) XY,
    max(CASE WHEN a.data_id=712 then a.DATA_Value END) HJ,
    max(CASE WHEN a.data_id=715 then a.DATA_Value END) KD,
    max(CASE WHEN a.data_id=666 then a.DATA_Value END) IK,
    max(CASE WHEN a.data_id=231 then a.DATA_Value END) GH,
    max(CASE WHEN a.data_id=881 then a.DATA_Value END) HH,
    max(CASE WHEN a.data_id=734 then a.DATA_Value END) KK,
    max(CASE WHEN a.data_id=734 then a.DATA_Value END) TK,
    max(CASE WHEN a.data_id=724 then a.DATA_Value END) TK,
    from FROM table_name group by 1,2
    We also tried pivot clause but still no major improvement in performance.
    There are about 40 such rows that we are trying to convert into columns. We created indexes, Primary, Secondary and referencial ones to tune this overall query. Also added paritions, We find this conversion works fine for smaller query, however for larger set of data we get high CPU and IO and also often runs into spool error. The data set we are runing on this query are about 3-4 TB. There is another table where we have about 100 rows which we need to convert into one row and again size goes to 4-5 TB
    Questions I have
    1) Is there better way to convert columns to Rows?
    2) What options can be use to reduce CPU, IO and Spool error?
    3) Does Orage 11g datawarehouse any feature which will hellp us here
    4) Any other appproach or design suggested here that will help us?
    This design is pushed by our business due to flexibility this design offers and we are runing into performance and we are trying to make this work without impacting CPU, Spool and IO
    Any suggestions would help us here, thanks for reading this

    Hi,
    Here's one way to do that:
    WITH     got_times     AS
         SELECT     MAX ( CASE
                   WHEN  msg_line = 'LONGITUDINAL REFRESH HAS BEGUN'
                   THEN  msg_datetime
                  )          AS start_time
         ,     MAX ( CASE
                   WHEN  msg_line = 'LONGITUDINAL REFRESH HAS COMPLETED'
                   THEN  msg_datetime
                  )          AS end_time
         FROM     xxwv.xxwv_hsum_info_reports
    SELECT     start_time
    ,     end_time
    ,     (end_time - start_time) * 24 * 60     AS duration_minutes
    FROM     got_times
    ;When you run the two different (but very similar) to get the two times, you have two different WHERE clauses. You can combine those two similar queries into one, but whatever WHERE clause you have will apply to the whole query. Whenever you wish you could apply a WHERE clause just to one column, think of CASE instead.

  • How to convert rows to columns

    Hi there,
    DB version Oracle 11g.
    this is my query ;
    select TO_CHAR(R_TARIHI, 'DAY'), TO_CHAR(T.BASLAMA,'HH24:MI') AS SAAT,(h.adi || ' ' ||h.soyadi) as HASTA
    from randevu_entegre t left outer join hasta h on h.id=t.hasta_id
    left outer join kod_randevu_turleri kr on kr.id=1
    where (R_TARIHI between to_Date('20.5.2011','dd.MM.yyyy') and (to_Date('20.5.2011','dd.MM.yyyy')+8))
    and (TO_CHAR(R_TARIHI, 'DY') NOT IN ('CMT','PAZ') )
    and DOKTOR_ID=224 order by t.baslama
    results table in this form                                          
    CUMA   
    13:30
    ORHAN SAVAS
    CUMA   
    14:00
    FATMA ETA
    CUMA   
    14:30
    ISMAHAN YALDIZ
    PAZARTESI
    13:00
    SEYHAN UNVER
    PAZARTESI
    13:30
    SELMA CALISKAN
    PAZARTESI
    17:45
    ESMA COMERT
    SALI   
    09:45
    SEYMA DURLANIK
    SALI   
    10:00
    HASAN GOC
    SALI   
    13:00
    TURKAN BICAK
    SALI   
    14:30
    ISMAHAN YALDIZ
    PERSEMBE
    08:30
    ZUHRE YEL
    PERSEMBE
    08:48
    AYSEL POLAT
    PERSEMBE
    09:00
    AHMET OZGUNGOR
    PERSEMBE
    09:12
    TELEFON RANDEVUSU
    can I convert my results table like this? Please help me.
    CUMA
    PAZARTESI
    SALI    
    PERSEMBE
    13:30 ORHAN SAVAS
    13:00 SEYHAN UNVER
    09:45 SEYMA DURLANIK
    08:30 ZUHRE YEL
    14:00 FATMA ETA
    13:30 SELMA CALISKAN
    10:00 HASAN GOC
    08:48 AYSEL POLAT
    14:30 ISMAHAN YALDIZ
    17:45 ESMA COMERT
    13:00 TURKAN BICAK
    09:00 AHMET OZGUNGOR
    14:30 ISMAHAN YALDIZ
    09:12 TELEFON RANDEVUSU

    hi Sarma,
    i visited to the link given by you & also reviewed the problems.but the question still in mind,with decode we can covert rows into columns but only where we have finite no of values in the row for eg. in deptno. we have just 4 types of values i.e. 10-40...
    but in case we have more than 20 distinct values in row & we have to make 20 column name from those 20 row values then we need 20 decode statements which is a lengthy process..do you have some other alternative regarding this.
    regards,
    Bhupinder Singh

  • Dynamic rows to columns oracle 10g

    Hi,
    I'm using oracle 10g. I have a requiriement where I need to show rows to columns. I have read through many posts but I couldn't find what I wanted to solve. Lots of them are using decode, since they know the values in one column.
    My table has name, value and date. I need to get values for each name at certain date (each distinct date needs to become column). I don't know the name beforehand.
    Name, Value, Date
    T1 100 06-27-2011 09:00:00
    T2 100 06-27-2011 09:00:00
    T1 200 06-27-2011 09:15:00
    T2 150 06-27-2011 09:15:00
    I would also need to use a date range. Someone can request date between 09:00:00 and 09:05:00 or 09:00:00 and 09:30:00 etc.
    I need to print
    Name, 06-27-2011 09:00:00, 06-27-2011 09:15:00
    T1 100 200
    T2 100 150
    Appreciate any advice on this.
    Edited by: user8801143 on 28-Jun-2011 08:23

    With 10g
    see http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:766825833740#2989343200346664698
    search for post on February 11, 2011 and reply on February 14, 2011
    with 11g see the pivot clause

  • How can i open a PDF bank statement in numbers so that the rows and columns contain properly aligned data from statement?

    how can i open a PDF bank statement in "numbers" so that the rows and columns contain properly aligned data from statement?

    Numbers can store pdfs pages or clippings but does not directly open pdf files.  To get the bank statement into Numbers as a table I would open the bank statment in Preview (or Skim) or some pdf viewer.
    Then hold the option key while selecting a column of data.
    Then copy
    Then switch to numbers and paste the column into a table
    Then repeat for the other columns in the pdf document
    It would be easier (in my opinion) to download the QFX or CSV version from your bank

  • How to accessing current row report column value in Lov Query?

    Hi,
    which access methods (eg. bind variables, substitutions, ...) for getting the current row report column value can be used in the "Lov Query" property of a report column?
    As what I know of and what I have read on the forum there are no bind variables for the report columns. For the "Link Text" property it seems that the column values exist as substitution strings (#COLUMN_NAME#). But they don't work in the Lov Query. => And would be good because of a hard parse each time the Lov query is executed.
    The following post (Re: Simulating a correlated sub query in lov
    is showing a solution to use package variables for temporary storage of the referenced value, but the only problem with that solution is that if a new record is added with the "Add rows to tabular form" process the package variable still contains the value from the last queried row! Is there a way (variable, APEX package, ...) to determine if the lov query is executed for a new record so that the package can return null?
    I know that I could write the package in a way that the value is immediately cleared when lov_pkg.keyval is called (one time read), but then I would have to create several variables if I'm accessing the value multiple times in the query or in another query => I think an one time read solution would be very obscurely.
    Thanks for your help
    Patrick
    http://inside-apex.blogspot.com

    Hi Patrick,
    I agree that it's a waste to continually use Ajax to go back to the server to get the contents of a dynamic select list.
    There are no bind variables for any row item - but what you do have, as per my previous post, is the value of the data entered by the user in the first row. You can pass this into your application process (using get.add("VARIABLENAME", value)), which can use it to retrieve the correct LOV in your Ajax code - this will give you a "bind variable" that your process can use.
    What you could do, however, is generate hidden select lists on your page - one for each possible LOV list and replace the contents of the new row's select list with the contents of the appropriate hidden select list. This is easy to do with javascript (using innerHTML functions). Obviously, though, the usefulness of this depends on the number and size of the select lists.
    Even if you don't generate them to start with, you can keep a copy of any select lists returned by Ajax in the DOM for use on new rows. So, if you have retrieved a select list, you will have a copy of it in DOM which you can then copy into the new row. If you don't have the list in DOM, use Ajax to get it, store a copy of it and copy it into the new row.
    Which method you use will depend on the number/size of select lists needed. If they are few in number and/or size, I would suggest generating hidden lists. If they are large, use Ajax to get them once, store them and then retrieve them from the DOM when needed.
    There is another thread here where Arie recommends going to the server every time to make sure you get the most up-to-date data for the lists. If you want to follow this advice, for this reason, use get.add("VARIABLENAME", value) to pass the value to your process. If this is not an issue, you can use one of the other methods I outlined above.
    Regards
    Andy

  • Row Selector column on Interactive Report

    Hi all,
    I have an interactive report based on a custom SQL query. How do I add a row selctor column so I cans select individual rows? I have also tried using a tabular form which also does not display a row selctor column. This is odd as my other tabular forms display a row selctor column.
    Many thanks for you help,
    Chris

    Chris,
    Usually when someone wants a row selector, it's to choose a few rows by clicking a checkbox, then doing something with them. I'm guessing that's what you're looking for?
    Martin Giffy D'Souza's [blog post|http://apex-smb.blogspot.com/2009/01/apex-report-with-checkboxes-advanced.html] explains one way to do that which should work for you. I haven't tried, it, but it looks pretty comprehensive.
    Good luck,
    Stew

  • How to create a report region which the first colomn is row selector column

    I want to create a report region and its first column is a row selector column. I have used select sentence to select some columns. But I do not know how set the first column to row selector column. I mean I want to do as follow. When a radio which is first column is chosen, it will return it's value of the column in the chosen row. Please help me! Thanks

    Hi unnamed,
    Suppose you have an id that identifies your record.
    Go to Report definiton, tab report attirbutes.
    Select the id of your record.
    Create a link to the page you want to go to.
    Hope this helps.
    If not, I suggest you to create a from with report, and analyze the way the wizard has generated it.
    Leo

  • How to get number of rows and columns in a two dimensional array ?

    Hello,
    What would be the simplest way to get number of rows and columns in a two dimensional array represented as integers ?
    I'm looking for another solution as For...Each loop in case of large arrays.
    Regards,
    Petri

    Hi Petri,
    See a attached txt file for obtaining two arrays with upper and lower index values
    Regards
    Ray
    Regards
    Ray Farmer
    Attachments:
    Get2DArrayIndex.txt ‏2 KB

  • How do I delete multiple rows and columns in an image?

    I am looking into how digital SLRs extract video data from a CMOS sensor. To give an example, the GH1 from Panasonic can record video at 1920 x 1080 from a 12 MPixel sensor that, say, is 4000 horizontal x 3000 vertical. How they do that seems to be not in the public domain, but there have been a few guesses (see http://www.dvxuser.com/V6/showthread.php?t=206797 and http://luminous-landscape.com/forum/index.php?showtopic=38713).
    One approach would be to simply read every second row of sensor pixels (1500 rows read from the original 3000) and once you have those in memory, delete every second column (2000 columns left). You would end up with a 2000 x 1500 image which could then be resampled to 1920 x 1080.
    I'd like to simulate what the camera appears to be doing, by generating a 4000 x 3000 test image and then asking Photoshop CS4 to delete the appropriate rows and columns. It may not necessarily be every second row; the Canon 5DMk11 appears to read every third row, so I may need to delete two out of every three rows.
    Can Photoshop do that sort of thing? If so, how?

    Thanks for the suggestions. Yes, I did take a detailed look at your images, but they weren't 100% convincing because it wasn't clear just what was happening. And Adobe's explanation, after reading it again, explains nothing at all to someone who doesn't know how Nearest Neighbor works.
    But you are correct -- Nearest Neighbor does effectively delete pixels. I proved it with the attached 6 x 6 image of coloured pixels (the tiny midget image right after this full stop -- you'll have to go to maximum zoom in PS to see it).
    These are the steps to delete every second row and then every second column.
    1. Select Image > Image Size.
    2. Set Pixel Dimensions > Height to half the original (in this case set to 3 pixels).
    3. Set Resample Image to Nearest Neighbor.
    4. Click OK and the image shoould now consist of three vertical white strips and three vertical Green-Red-Blue stripes.
    5. Repeat steps 1-4, but this time set Pixel Dimensions > Width to half the original (in this case set to 3 pixels). The image should now consist of three horizontal stripes Green-Red-Blue.
    Just to make sure the method worked for every third pixel, I repeated the above steps but with 2 pixels instead of 3 and obtained the correct White-Green, White-Green pattern.
    I resampled the Height and Width separately for the test so that I could see what was happening. In a real example, the height and width can be changed at the same time in the one step, achieving the same results as above.
    Finally, how to explain how Nearest Neighbor works in the simple cases described above?
    Division by 2
    In the case of an exact division by two (pixels numbered from top leftmost pixel), only the even numbered rows and columns remain. To put it a different way, every odd numbered row and column are deleted.
    Division by 3
    Only rows and columns 2, 5, 8, 11... remain.
    Division by N
    Only rows and columns 2, 2+N, 2+2N, 2+3N... remain.
    To put it simply, a resample using Nearest Neighbor (using an exact integer multiple) keeps every Nth row and column, starting from number two. The rest are deleted.

  • Lock rows and columns header in a table view report. It is possible?

    hi,
    I have a Dashboard that displays a report in "Table View" with many rows and columns.
    Is it possible to set a lock on the rows and columns like Excel?
    This would have blocked such headers that contain attributes and measures and to browse the report (eg with a scroll bar) had always viewed the headers.
    Can you help me?
    Thanks

    hi,
    please go through this discussion
    Re: SCROLL BAR to FREZZ HEADERS
    thanks,
    saichand.v

  • Is it possible to switch the rows and columns?

    Is it possible to switch the rows and columns of a table? The reason I ask is that it would be easier for me to input the data with the number at the top of a column and the fields going down. But it would be easier to read the data with the number on the left and the fields going to the right. Is it possible to switch a table in this way?

    mahongue wrote:
    Is it possible to switch the rows and columns of a table? The reason I ask is
    that it would be easier for me to input the data with the number at the top
    of a column and the fields going down. But it would be easier to read the
    data with the number on the left and the fields going to the right. Is it
    possible to switch a table in this way?
    It sounds to me as though you wish to transpose a table so that the original is changed from rows to columns and from columns to rows, as in the following:
    Table 1
        A   B   C
    ========
    1   o   p   q
    2   r   s   t
    3   u   v   w
    Table 2
        A   B   C
    ========
    1   o   r   u
    2   p   s   v
    3   q   t   w
    You are right - it would be nice to have a menu item to magically transpose a selected block of cells. But there isn't one. So...
    One way to solve this is to use the index() and transpose() functions to accomplish row and column cell transposition. If you are going to use a 1:1 cell correspondence and change the header columns and rows also, you can use this:
       =INDEX(TRANSPOSE(Table # :: <range>),ROW(),COLUMN())
    where Table # and <range> is substituted as in the following fashion:
       =INDEX(TRANSPOSE(Table 1 :: $A$1:$C$3),ROW(),COLUMN())
    Create a second table. Copy the modified formula above with the appropriate substitutions, select the range you wish to have your transposition inserted into (must match the transposed cell dimensions of the original range), paste the forumula and voila! the cells will be transposed.
    Cautions:
    o The target table must match the swapped cell length and width dimension. For example, if the original data range is 6 columns wide by 4 rows deep, then the corresponding table or range to hold the transposition must be 4 columns wide by 6 rows deep.
    o If your transposed data block is to be offset from the origin of the new table, then you will need to include a subtractive offset into your cell formula, since in the transpose() function the data in the master data range is referenced from its position with the master range, not its cell position in the table. Such an offset is necessary because this example formula uses the target row and column numbers to arrive at indexed positions.
    For example, if the new data range is to be offset one column to the right and one row below from the target table's origin then you must subtract (-1) from the cell and from the column references in the formula:
      Example:
      =INDEX(TRANSPOSE(Table 3 :: $B$2:$D$4),ROW()-1,COLUMN()-1)
    If someone has a better solution I'd be glad to hear of it.

  • How Calculate more than one value and store it into to different rows and column for each input?

    thx guys.....i have a progress now in LV
    But now i have new trouble here. Ok i attached my LV file (LV 7.0.1/7.1) and excel form. I just could'nt calculate more than one input value. I want a different result for each value that i enter ... and store it into different rows and column. But it just store at one row.
    Attachments:
    My Project.vi ‏31 KB
    rumus motor bakar.xls ‏14 KB

    duplicate post

Maybe you are looking for