Convert values in a row to columns in oracle 8i

Hi All,
I have a small query to be wrritten in 8i
consider the table
Name|test1|test2|test3|.....|testn
hai 1 2 3 ..... n
dai 11 22 33 nn
I want the output to be
hai 1
hai 2
hai 3
hai n
dai 11
dai 22
dai 33.
Please give ur solutions for this

SELECT *
  FROM (SELECT name, column1 val
          FROM table_name
        UNION ALL
        SELECT name, column2 val
          FROM table_name
        UNION ALL
        SELECT name, columnN val
          FROM table_name)
ORDER BY nameJustin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • Hi, how can i break the value for a row and column once i have converted the image to the array?????​??

    Hi, I would like to know how can i break the value for a row and column once i have converted the image to the array. I wanted to make some modification on the element of the array at a certain position. how can i do that?
    At the moment (as per attachhment), the value of the new row and column will be inserted by the user. But now, I want to do some coding that will automatically insert the new value of the row and the column ( I will use the formula node for the programming). But the question now, I don't know how to split the row and the column. Is it the value of i in the 'for loop'? I've  tried to link the 'i' to the input of the 'replace subset array icon' , but i'm unable to do it as i got some error.
    Please help me!
    For your information, I'm using LABView 7.0.

    Hi,
    Thanks for your reply.Sorry for the confusion.
    I manage to change the array element by changing the row and column value. But, what i want is to allow the program to change the array element at a specified row and column value, where the new value is generated automatically by the program.
    Atatched is the diagram. I've detailed out the program . you may refer to the comments in the formula node. There are 2 arrays going into the loop. If a >3, then the program will switch to b, where if b =0, then the program will check on the value of the next element which is in the same row with b but in the next column. But if b =45, another set of checking will be done at a dufferent value of row and column.
    I hope that I have made the problem clear. Sorry if it is still confusing.
    Hope you can help me. Thank you!!!!
    Attachments:
    arrayrowncolumn2.JPG ‏64 KB

  • Converting key figures from rows to column using DSO and start routine

    Hi SDNer:
    I need some help to convert key figures from rows to column.
    The source is DSO 1 and I am thinking about writing ABAP in the start routine to do the conversion. The target is DSO2.
    Below is the  more detail information with example. Basically, for each record in DSO 1 I need to create 3 records (because there are 3 KF's) and output to DSO2.
    I would really appreciate some help on this.Thank you.
    Tony
    DSO 1 data format (SOURCE)
    Period   ID   KF1  KF2  KF3
    200702 100  300  200   750
    Output to DSO 2 (TARGET)
    Period   ID    KF  LABEL
    200702 100  300  KF1
    200702 100  200  KF2
    200702 100  750  KF3

    This is the code in BI 7.0.
    u need to put a field "Label" in DSO1. u dont need to populate this in DSO1 but it helps the code to populate the field in DSO2.
    DATA: wa_result TYPE _ty_s_sc_1,
    t_result TYPE STANDARD TABLE OF _ty_s_sc_1.
    DATA:counter(2) TYPE n.
    LOOP AT SOURCE_PACKAGE INTO wa_result.
    counter =0.
    while counter < 3 .
    wa_result- Period = wa_result-Period.
    wa_result- ID = wa_result-ID.
    if counter  = 0.
    wa_result- KF1 = wa_result-KF1.
    wa_result- Label = 'KF1'.
    elseif counter = 1.
    wa_result- KF1 = wa_result-KF2.
    wa_result- Label = 'KF2'.
    else.
    wa_result- KF1 = wa_result-KF3.
    wa_result- Label = 'KF3'.
    endif.
    APPEND wa_result TO t_result.
    counter = counter+1.
    endwhile.
    endloop.
    CLEAR: SOURCE_PACKAGE,wa_result.
    LOOP AT t_result INTO wa_result.
    APPEND wa_result TO SOURCE_PACKAGE.
    ENDLOOP.

  • Converting Rows into Column in Oracle 10g

    Hi All,                    
    I m using Oracle Version 10.1.0.2.0 - Production                    
    I have requirement to convert rows into column wise as per the following:                    
    My Query is:                    
    WITH t                    
    AS ( SELECT 'A' AS x, 100 AS y FROM DUAL                     
    UNION ALL                    
    SELECT 'B',200 FROM DUAL                    
    SELECT X, Y                    
    FROM t;     
    X Y
    A 100
    B 200
    My Requirement is
    A B
    100 200
    So any one could help me that how I resolve this.
    Regards,
    Prasanta

    Dear frank,
    Thanks for your support,.
    It's working fine for static cases.If the first column is dynamic then how come i will resolve it.
    Example:
    Create table mytab (ID_C Varchar2(15),Value_N Number);
    Records Population into MyTab table is dynamic.
    Insert into mytab values('HO',5000);
    Insert Into mytab values('PG1',2400);
    Insert Into mytab values('PG2',3000);
    Insert Into mytab values('PG3',800);
    Commit;
    SQL> Select * From MyTab;
    IDC_ ValueN_
    HO 5000
    PG1 2400
    PG2 3000
    PG3 800
    Then My expected result will be as follows
    HO PG1 PG2 PG3
    5000 2400 3000 800
    Thanks and Regards,
    Prasanta

  • Convert rows to Columns in Oracle

    Hi,
    The table like
    Trx         Date
    PO121 23/11/2008
    PO122 24/11/2008
    PO123 25/11/2008
    I want to convert all the rows to columns like the below table
    PO121    23/11/2008    PO122    24/11/2008       PO123     25/11/2008
    Is it possible in Oracle ?

    Like this
    SQL> WITH T
      2  AS
      3  (
      4     SELECT 'PO121 23/11/2008' VAL FROM DUAL
      5     UNION ALL
      6     SELECT 'PO122 24/11/2008' FROM DUAL
      7     UNION ALL
      8     SELECT 'PO123 25/11/2008' FROM DUAL
      9  )
    10  SELECT MAX(DECODE(RNO,1,VAL)) VAL1, MAX(DECODE(RNO,2,VAL)) VAL2, MAX(DECODE(RNO,3,VAL)) VAL3
    11    FROM (SELECT ROW_NUMBER() OVER(ORDER BY VAL) RNO, VAL
    12       FROM T)
    13  /
    VAL1             VAL2             VAL3
    PO121 23/11/2008 PO122 24/11/2008 PO123 25/11/2008But beware the number of column must be known. without that you cant do it in a static SQL.
    Edited by: Karthick_Arp on Nov 10, 2008 1:41 AM

  • Pivoting rows into columns in Oracle 10g

    Hi,
    I want to pivot rows into column in some optimal way.
    I don't want to go with the DECODE option as the number of columns can be more than 200.
    i have also tried the transpose logic which is making the pl/sql block too huge.
    can i directly query the database for the desired output instead of storing the data into some arrays and displaying rows as columns?

    Hi,
    Here's a dynamic way to do this is Oracle 10, using theSQL*Plus @ command to handle the dynamic parts.
    First, let's see how we would do this using a static query:
    WITH     col_cntr    AS
         SELECT     column_name
         FROM     all_tab_columns
         WHERE     owner          = 'FKULASH'
         AND     table_name     = 'TEST_EMP'
         AND     column_name     NOT IN ('EMP_ID', 'TYPE_VAL')
    ,     unpivoted_data     AS
         SELECT     e.type_val
         ,     c.column_name
         ,     CASE c.column_name
                  WHEN  'X_AMT'  THEN  x_amt     -- *****  Dynamic section 1  *****
                  WHEN  'Y_AMT'  THEN  y_amt     -- *****  Dynamic section 1  *****
                  WHEN  'Z_AMT'  THEN  z_amt     -- *****  Dynamic section 1  *****
              END     AS v
         FROM          test_emp  e
         CROSS JOIN     col_cntr  c
    SELECT       column_name     AS type_val
    ,       SUM (CASE WHEN type_val = 'Q1' THEN v ELSE 0 END)     AS q1     -- ***** Dynamic section 2  *****
    ,       SUM (CASE WHEN type_val = 'Q2' THEN v ELSE 0 END)     AS q2     -- ***** Dynamic section 2  *****
    ,       SUM (CASE WHEN type_val = 'Q3' THEN v ELSE 0 END)     AS q3     -- ***** Dynamic section 2  *****
    ,       SUM (CASE WHEN type_val = 'Q4' THEN v ELSE 0 END)     AS q4     -- ***** Dynamic section 2  *****
    FROM       unpivoted_data
    GROUP BY  column_name
    ORDER BY  column_name
    ;Column names are hard-coded in two places:
    (1) in the sub-query unpivoted_data, we had to know that there were 3 columns to be unpivoted, and that they were called x_amt, y_amt and z_amt. You want to derive all of that from all_tab_columns.
    (2) in the main query, we had to know that there would be 4 pivoted columns in the rsult set, and that they would be called q1, q2, q3 and q4. You want to derive all that from the data actually in test_emp.
    Instead of hard-coding those 2 dynamic sections, have Preliminary Queries write them for you, a split second before you run the main query, by running this script:
    --  Before writing sub-scripts, turn off features designed for human readers
    SET     FEEDBACK    OFF
    SET     PAGESIZE    0
    PROMPT *****  Preliminary Query 1  *****
    SPOOL     c:\temp\sub_script_1.sql
    SELECT    '              WHEN  '''
    ||       column_name
    ||       '''  THEN  '
    ||       LOWER (column_name)     AS txt
    FROM       all_tab_columns
    WHERE       owner          = 'FKULASH'
    AND       table_name     = 'TEST_EMP'
    AND       column_name     NOT IN ('EMP_ID', 'TYPE_VAL')
    ORDER BY  column_name
    SPOOL     OFF
    PROMPT     *****  Preliminary Query 2  *****
    SPOOL     c:\temp\sub_script_2.sql
    SELECT DISTINCT  ',       SUM (CASE WHEN type_val = '''
    ||                type_val
    ||           ''' THEN v ELSE 0 END)     AS '
    ||           LOWER (type_val)          AS txt
    FROM           test_emp
    ORDER BY      txt
    SPOOL     OFF
    --  After writing sub-scripts, turn on features designed for human readers
    SET     FEEDBACK    5
    SET     PAGESIZE    50
    -- Main Query:
    WITH     col_cntr    AS
         SELECT     column_name
         FROM     all_tab_columns
         WHERE     owner          = 'FKULASH'
         AND     table_name     = 'TEST_EMP'
         AND     column_name     NOT IN ('EMP_ID', 'TYPE_VAL')
    ,     unpivoted_data     AS
         SELECT     e.type_val
         ,     c.column_name
         ,     CASE c.column_name
                  @c:\temp\sub_script_1
              END     AS v
         FROM          test_emp  e
         CROSS JOIN     col_cntr  c
    SELECT       column_name     AS type_val
    @c:\temp\sub_script_2
    FROM       unpivoted_data
    GROUP BY  column_name
    ORDER BY  column_name
    ;As you can see, the main query looks exactly like the static query, except that the two dynamic sections have been replaced by sub-scripts. These 2 sub-scripts are written by 2 prelimiary queries, right before the main query.
    As others have said, the fact that you're asking this question hints at a poor table design. Perhaps the table should be permanently stored in a form pretty much like unpivoted_data, above. When you need to display it with columns x_amt, y_amt, ..., then pivot it, using GROUP BY type_col. When you need to display it with columns q1, q2, ..., then pivot it using GROUP BY column_name.

  • Display last value from a row or column?

    I'm using Numbers 09 and want to display the last value entered in a column in another table.
    For example in Table A I have columns set up by date with simple sums at the bottom of each column. I add new sums every day depending on the values from that day. What I'd like to do is get the last daily total and enter that value into another table called Table B. Is there a formula that will do that?
    If I'm not being clear enough please let me know what additional information you need and I will be happy to provide it.
    Thanks,
    rkaufmann87

    rkaufmann87 wrote:
    Hi Barry,
    Thanks for posting the example, not quite though. In your sample Table A is transferring all the totals to Table B. What I'd like is as I enter the data in the columns in Table A Table B then picks up the latest update in a single cell. For example lets say Table A's Column A is May 1 and the total is 45, let's say that sum is placed in A15. Table B automatically picks up A15 from Table A and makes a duplicate in Table B cell A1, then the next day Table A's Column B is May 2 and the total is 90 (cell B15), then Table B senses the latest total is 90 and enters that in cell A1 again. Is this possible?
    Here's another go.
    Table 1 has a second Header row added (row 2) Cells in this row contain the formula
    =IF(A1=MAX($1:1),COLUMN(),"")
    Which returns the column number of the cell in row 1 containing the latest date. (4) This number is used by Table 2 to determine the column from which to return the total in the bottom (footer) row. (see below)
    A1 in Table 2 and Table 3 contain the same formula:
    =MAX(Table 1 :: $1:1)
    This returns the latest date from row 1 of Table 1.
    A2 in Table 2 and Table 3 contain formulas that return the value in the bottom cell of the column containing the latest date in row 1.
    Table 2:   =OFFSET(Table 1 :: $A$1,ROWS('May 1, 2010')-1,MAX(Table 1 :: $2:2)-1)
    Table 3:   =OFFSET(Table 1 :: $A$1,ROWS('May 1, 2010')-1,COUNT(Table 1 :: $1:1)-1)
    Both use the same base ($A$1) and the same row offset (ROWS('May 1, 2010')-1) to reach the bottom row of Table 1.
    Table 2 uses the maximum (and only) numerical value in row 2 of Table 1 ( MAX(Table 1 :: $2:2) ), then subtracts 1 to reach the fourth column of table 1.
    Table 3 uses the same means to determine the row offset, but counts the number of dates entered into row 1 of Table 1 ( COUNT(Table 1 :: $1:1) ), then subtracts 1 to reach the same cell.
    I prefer the method in Table 3 because it avoids the need for the second Header row and the possibility of overwriting the formulas in that row. (Row 2 of Table 1 may be deleted without affecting Table 3.) It does require that there be no empty cells in Row 1 from Column A to the column containing the latest date.
    Regards,
    Barry

  • Convert Row to Columns in Oracle

    i have table data like
    PHASE_NAME     SUB_PHASE_NAME     ACTIVITY_NAME     MANDATORY
    Pre Planting     Till/Cultivation     Environment Conditions     y
    Pre Planting     Till/Cultivation     Irrigation     n
    Pre Planting     Till/Cultivation     Soil Analysis     n
    Pre Planting     Till/Cultivation     Crop Analysis     n
    Pre Planting     Till/Cultivation     Other Observations,     n
    Pre Planting     Till/Cultivation     Weather Observations     n
    Pre Planting     Till/Cultivation     Water Analysis     n
    i want result like
    PHASE_NAME     SUB_PHASE_NAME     Environment Conditions     Irrigation     Soil Analysis     Crop Analysis     Other Observations,     Weather Observations     Water Analysis
    Pre Planting     Till/Cultivation     y     n     n     n     n     n     n

    Please consider the following when you post a question.
    1. New features keep coming in every oracle version so please provide your Oracle DB Version to get the best possible answer.
    You can use the following query and do a copy past of the output.
    select * from v$version 2. This forum has a very good search feature. Please use that before posting your question. Because for most of the questions
    that are asked the answer is already there.
    3. We dont know your DB structure or How your Data is. So you need to let us know. The best way would be to give some sample data like this.
    I have the following table called sales
    with sales
    as
          select 1 sales_id, 1 prod_id, 1001 inv_num, 120 qty from dual
          union all
          select 2 sales_id, 1 prod_id, 1002 inv_num, 25 qty from dual
    select *
      from sales 4. Rather than telling what you want in words its more easier when you give your expected output.
    For example in the above sales table, I want to know the total quantity and number of invoice for each product.
    The output should look like this
    Prod_id   sum_qty   count_inv
    1         145       2 5. When ever you get an error message post the entire error message. With the Error Number, The message and the Line number.
    6. Next thing is a very important thing to remember. Please post only well formatted code. Unformatted code is very hard to read.
    Your code format gets lost when you post it in the Oracle Forum. So in order to preserve it you need to
    use the {noformat}{noformat} tags.
    The usage of the tag is like this.
    <place your code here>\
    7. If you are posting a performance related question. Please read
       {thread:id=501834} and {thread:id=863295}.
       Following those guide will be very helpful.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • ROW TO COLUMN in Oracle 10G

    Hi all,
    I have requirement to display the values in a single column base upon the empid
    ex:
    select * from emp where empid=1000
    then actual result will come as
    empid mgr dept sal
    1000 10    10    1000
    1000 20    20    2000
    2000 10   10    1500
    2000 20   20    3000but i want the result in the below format
    for empid 1000 the result will show as
    empid mgr dept sal    mgr2 dept2 sal2
    1000 10    10   1000 20    20    2000
    2000 10   10    1500 20   20    3000Can anyone help me out to achieve this?
    Cheers,
    San

    something like this
    SQL> ed
    Wrote file afiedt.buf
      1  with t as
      2  (
      3  select 1000 empid, 10 mgr,    10 dept,    1000 sal from dual union all
      4  select 1000, 20,    20 ,   2000 from dual union all
      5  select 2000 ,10 ,  10   , 1500  from dual union all
      6  select 2000 ,20  , 20    ,3000 from dual
      7  )
      8  select empid,
      9  max(decode(mgr,10,mgr)) mgr1,
    10  max(decode(mgr,20,mgr)) mgr2,
    11  max(decode(dept,10,dept)) dept1,
    12  max(decode(dept,20,dept)) dept2,
    13  max(decode(mgr,10,sal)) sal1,
    14  max(decode(mgr,20,sal)) sal2
    15  from t
    16* group by empid
    SQL> /
         EMPID       MGR1       MGR2      DEPT1      DEPT2       SAL1       SAL2
          1000         10         20         10         20       1000       2000
          2000         10         20         10         20       1500       3000

  • 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

  • Rows into column

    Hi,
    I have a table service_request_master where a column has data like
    Srid function_activity_id
    1001 12,13,14
    1002 11,12
    1003 null
    1004 19
    I need to convert function_activity_ids for each row into columns i.e.
    for 1001 it would be 12
    13
    14
    for 1002 11
    12
    and so on..
    I wrote this query but it is not workig for multiple rows:
    WITH   row_count as (
      select length(
               ltrim(
                 rtrim(
                   translate(function_activity_ids, ',1234567890 ', ',')
             ) + 1 rc,
             ',' || function_activity_ids || ',' function_activity_ids
        from sop_service_request)
    select substr(function_activity_ids,
             instr(function_activity_ids, ',', 1, rownum) + 1, -- start_pos
             instr(function_activity_ids, ',', 1, rownum + 1) -
                 instr(function_activity_ids, ',', 1, rownum) - 1 -- data_length
           ) new_data,
           function_activity_ids,
           rc
       from row_count,   
            all_tables
      where rownum <= rccan you pls help..
    a generic function would also do...
    Thx,..
    JP

    JP,
    I don't know exactly what you want with that null column, but try this:
    SQL> create table service_request_master
      2  as
      3  select 1001 srid, '12,13,14' function_activity_id from dual union all
      4  select 1002, '11,12' from dual union all
      5  select 1003, null from dual union all
      6  select 1004, '19' from dual;
    Tabel is aangemaakt.
    SQL>
    SQL> select srm.srid
      2       , case numbers.n
      3         when 1 then
      4              case instr(srm.function_activity_id,',',1,1)
      5              when 0 then srm.function_activity_id
      6              else substr(srm.function_activity_id,1,instr(srm.function_activity_id,',',1,1)-1)
      7              end
      8         else substr
      9              ( srm.function_activity_id
    10              , 1 + instr(srm.function_activity_id,',',1,numbers.n-1)
    11              , case instr(srm.function_activity_id,',',1,numbers.n)
    12                when 0 then length(srm.function_activity_id)
    13                            - instr(srm.function_activity_id,',',1,numbers.n-1) + 1
    14                else instr(srm.function_activity_id,',',1,numbers.n)
    15                     - instr(srm.function_activity_id,',',1,numbers.n-1) - 1
    16                end
    17              )
    18         end single_id
    19    from service_request_master srm
    20       , ( select level n from dual connect by level <= 3 ) numbers
    21   where length(srm.function_activity_id) - length(replace(srm.function_activity_id,',')) + 1
    22         >= numbers.n
    23   order by srm.srid
    24       , single_id
    25  /
                                      SRID SINGLE_I
                                      1001 12
                                      1001 13
                                      1001 14
                                      1002 11
                                      1002 12
                                      1004 19
    6 rijen zijn geselecteerd.Regards,
    Rob.

  • Values trimed while inserting in column

    Hi Experts,
    I tried to insert value 'T%&U' in a column of oracle database table, but the value 'T%' is get inserted in the column. string after % is skiped. Can anyone tell me why this happened?
    Thanks

    set define off to achieve the desired result
    Here is the example
    SQL> create table test
    2 ( str_1 varchar2(10));
    Table created.
    SQL> insert into test values('T%&U');
    Enter value for u:
    old 1: insert into test values('T%&U')
    new 1: insert into test values('T%')
    1 row created.
    SQL> set define off
    SQL> insert into test values('T%&U');
    1 row created.
    SQL> select * from test;
    STR_1
    T%
    T%&U
    HTH,
    ~Yogesh

  • Search row and column for return value

    Dear Sir/Madam,
                               I have a problem for searching spreadsheet and hope you can help me out a bit.  Im pretty new to Labview and Im currently using Labview 8.0.  My task is to search the spreadsheet I have attached in row and column-wise, then return the corresponding value out.  I had an attempt in doing this as you can see from the vi that i have attached.  I try inputting the 'read from measurement file' into an array and using delete, index and search array I will be able to find the index value for the relevant row and column that i searched for by inputting them into an index array with the orginal array from the 'read from measurement file'.
                              So ultimately, when i enter a row value of 0.5 and a column value of 0.3, my output will be 1.688.
                              I can't see any mistakes in my logic but I getting really strange results, like I can read my data has been entered into an array but when i try deleting the first column and put it into another array, the orginal array with nothing deleted is outputted hence making my search to give out -1 value. So could you take a look please and give me any suggestion that can solve my problem or enhance the code a bit.  Thank you for your time.
    Best Regards,
    Coato
    P.s for some reason i can't attached the .lvm file of my data hence i have attached the excel version but i think you need to convert it back to .lvm for the 'read from measurement file' function to work.
    Attachments:
    Backswing compensation.csv ‏10 KB
    Backswing comnpensation2.vi ‏109 KB

    Your VI makes absolutely no sense to me, but maybe I don't understand what you are trying to do.
    You seem to have dynamic data with 6 signals and 48 points/channel. Now you reshape this into an array of dynamic data with 4x13 elements from which you slice out one row or column, resp. "delete from array" is NOT the correct tool to do this, use "Index array" with one index unwired to get a row or column as 1D array.
    So you end up with two 1D arrays of dynamic data that you search for DBL. It is difficult to understand how you want to search for an array element that corresponds to a scalar DBL value of 0.1. Your array elements are NOT DBLs but dynamic data, each containing many signals!
    There are two elements on all your data that are "3", the rest are zero. You will never find anything that is 0.1.
    Maybe you can convert your original dynamic data to a 2D array with "rows are signals" using "convert from dynamic data", then operate on the 2D array.
    Coato wrote:
                              So ultimately, when i enter a row value of 0.5 and a column value of 0.3, my output will be 1.688.
    Sorry, Please explain.
    Please make a VI containing a simple 2D aray as diagram constant that contains e.g. 5x5 typical values. Let us know what kind of result you expect from your algorithm..
    LabVIEW Champion . Do more with less code and in less time .

  • Group by and then convert form Row to column

    Hi All,
    below is a transaction table for bank customer.
    region_id     cutomer_id     transaction_type     transaction_date
    101          12345          CC               10-March-2011
    101          12345          DC               07-March-2011
    101          12345          P1               01-March-2011
    101          12345          p2               10-Jan-2011
    102          45678          CC               15-feb-2011
    101          12345          p3               27-OCT-2010with combinaton of region_id and customer_id, we get uniq record from the table. There are also different kind of transaction a customer has done. It is given in transaction_type column (CC - Credit card, Dc - Debit Card, and those start with P% {including P1, p2, p3} = payment).
    Now my requirement is to get the number of transaction for each transaction type for a current year and also number of total transaction by the customer. Below is my output table.
    region_id     cutomer_id     transaction_type     transaction_date     Tran_type_cc     Tran_type_DC     Tran_type_P     count_tran
    101          12345          CC               10-March-2011          1          1          2          5
    101          12345          DC               07-March-2011          1          1          2          5
    101          12345          P1               01-March-2011          1          1          2          5
    101          12345          p2               10-Jan-2011          1          1          2          5
    102          45678          CC               15-feb-2011          1          0          0          1
    101          12345          p3               27-OCT-2010          1          1          2          5if i do group by it gives me result but at row level and to convert row into column to get above result, i need to use decode function. My sourcec is containing 25 miliion records, and if i execute the query, it is getting hanged. Can someone help me how can i write a fine tuned query by using analytical function

    How about this?
    Note: I suppose, p1, P1, p2, P2, p3, P3 all belong to the same payment category regardless of their upper/lower case.
    Here is the table and the data:
    CREATE TABLE T1 (REGION_ID NUMBER, CUSTOMER_ID NUMBER, TRAN_TYPE VARCHAR2(5), TRAN_DATE DATE);
    INSERT INTO T1 VALUES (101, 12345, 'CC', TO_DATE('10-Mar-2011','DD-MON-YYYY'));
    INSERT INTO T1 VALUES (101, 12345, 'DC', TO_DATE('07-Mar-2011','DD-MON-YYYY'));
    INSERT INTO T1 VALUES (101, 12345, 'P1', TO_DATE('01-Mar-2011','DD-MON-YYYY'));
    INSERT INTO T1 VALUES (101, 12345, 'p2', TO_DATE('10-Jan-2011','DD-MON-YYYY'));
    INSERT INTO T1 VALUES (102, 45678, 'CC', TO_DATE('15-FEB-2011','DD-MON-YYYY'));
    INSERT INTO T1 VALUES (101, 12345, 'p3', TO_DATE('27-OCT-2010','DD-MON-YYYY'));Here is the query:
    SELECT REGION_ID, CUSTOMER_ID, TRAN_TYPE, TRAN_DATE
      , SUM(DECODE(TRAN_TYPE, 'CC', '1','0')) OVER (PARTITION BY CUSTOMER_ID) AS CC
      , SUM(DECODE(TRAN_TYPE, 'DC', '1', '0')) OVER (PARTITION BY CUSTOMER_ID ) AS DC
      , SUM(DECODE(SUBSTR(UPPER(TRAN_TYPE), 1,1) , 'P', '1','0')) OVER (PARTITION BY CUSTOMER_ID) AS P
      , SUM(1) OVER (PARTITION BY CUSTOMER_ID) AS TRAN_T
    FROM T1 ;
    r_id   cust_id      t_TYPE   T_DATE  CC_CNT  DC_CNT  P_CNT  T_CNT
    101     12345     CC     10-MAR-11     1     1     3     5
    101     12345     DC     07-MAR-11     1     1     3     5
    101     12345     p3     27-OCT-10     1     1     3     5
    101     12345     p2     10-JAN-11     1     1     3     5
    101     12345     P1     01-MAR-11     1     1     3     5
    102     45678     CC     15-FEB-11     1     0     0     1Edited by: PhoenixBai on Mar 14, 2011 4:16 PM

  • Coverting a Row into Columns values

    Hi SQL Expert Friends,
    I have a row which contains 6 columns where I want that data to be shown in the form of columns as shown here:
    From:
    select item1, item2, item3, amt1, amt2, amt3 from item_table where sno=1; <----- returns 1 row as below
    ITEM1 ITEM2 ITEM3 AMT1 AMT2 AMT3
    AAA BBB CCC 10.00 20.00 15.00
    Data explanation: item1's (AAA) price is amt1 (10.00), item2's (BBB) price is amt2 (20.00) and item3's (CCC) price is amt3 (15.00). OK.
    Now I want that data to convert into columns as shown here:
    To:
    ITEMS AMT
    AAA 10.00
    BBB 20.00
    CCC 30.00
    Please help me friends, I want a SQL to display this data.
    I found one query which converts a row into columns, but this does not serve my requirement: [for your reference only]
    SQL> select substr( the_string
    , decode( level, 1, 1, instr(the_string,',',1,level-1)+1)
    , decode( instr(the_string,',',1,level), 0, length(the_string), instr(the_string,',',1,level) - decode( level, 1, 0, instr(the_string,',',1,level-1))-1)
    ) the_value
    from ( select (select item1||','||item2||','|| item3 from item_table where sno=1) ITEMS
    from DUAL)
    connect by level <= length(the_string)-length(replace(the_string,','))+1
    Thanks and REgards,
    Kiran

    Hi, Kirtan,
    kiran wrote:
    ... I want to learn this query, If you could explain me this how it works, then it will definitely helps me.If you don't understand a query that involves sub-queries, make sure you understand the sub-queries first. Run them separately, and study the results.
    In this case, the only sub-query is cntr. Run it separately, like this:
    WITH     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL     <= 3
    SELECT    *
    FROM       cntr;Output:
    `        N
             1
             2
             3Why did I use the number 3 in "LEVEL <= 3"? Because each row will be unpivoted onto 3 rows. You could make this number 2, or 5, or 25 if that's how many rows you want in the output.
    Once you understand the sub-queries, try running the main query. Include the raw values of all columns that play any part in the output. For example:
    WITH     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL     <= 3
    SELECT       CASE  cn.n
               WHEN  1  THEN  co.city1
               WHEN  2  THEN  co.city2
               WHEN  3  THEN  co.city3
           END          AS cities
    ,       CASE  cn.n
               WHEN  1  THEN  co.population1
               WHEN  2  THEN  co.population2
               WHEN  3  THEN  co.population3
           END          AS population
    ,       co.*          -- For testing/understanding only
    ,       cn.*          -- For testing/understanding only
    FROM             continent     co
    CROSS JOIN     cntr          cn
    WHERE     co.country     = 'America'
    ;Output:
    `            POPUL                                       POPUL  POPUL  POPUL
    CITIES       ATION COUNTRY  CITY1   CITY2       CITY3   ATION1 ATION2 ATION3  N
    Phoenix      20000 America  Phoenix Los Angeles Chicago  20000  15000  10000  1
    Los Angeles  15000 America  Phoenix Los Angeles Chicago  20000  15000  10000  2
    Chicago      10000 America  Phoenix Los Angeles Chicago  20000  15000  10000  3Why are there 3 rows of output? There are 3 rows in the cntr "table", and 3 rows in the continent table. Of these 3 * 3 = 9 rows, only the 3 rows shown above meet the condition in the WHERE clause. (Comment out the WHERE clause and try it again, if you want to see how that works.) Can you see how you get the output (the first 2 columns above) given all the data in the original columns? If not, ask a more specific question about the part you don't understand.

Maybe you are looking for

  • Stil image (photo) quality in rendered project

    I'm having an issue with the quality of photos that I've added to a video. The quality of the still photo exhibits a lot of "jagged" edges along things that should be straight lines. Photos of stone walls look almost like the stones are vibrating. Th

  • TS1717 iTunes broken since update. Any ideas?

    Since the update, not only can I not access the iTunes store (It begins to load, but crashes within seconds, freezing my whole computer), but my library is messing up too. I can't skip ahead on videos, and some won't even load at all. I have tried un

  • Inspection lot for a cost center purchase

    Hello , After the results recording , it is not possible to go any good movement in the UD screen . Why SAP is not recommending one more goods movement for a cost center purchase ? Thanks for your help JN

  • How to document for storage location summary

    Dear All, I am using this how to document and applying it to my scenario. Has anybody implemented this how to document? My question was supposed I have some additional key figures in the report, say apart from ValStockValue and Total Stock, I have st

  • Downloading Netweaver Abap Trial Version

    Hi Everybody, I am having free download manager installed in my computer. The moment it picks to download the software Netweaver Abap, it says "STOPPED"  and does not proceeds further. Is there any settings in it to correct it or is there any other d