single request to divide the value

[code]

Hi Experts,

I need help to solve a small problem.  I have a table and values as below

1A

1 B

1 C

1 D

Now, I need a single query to return the lines as below

1 A, B

1 A, C

1 A, D

I tried with the list_agg function, but which returns the values as

1 A, B, C, D

Can someone please

Thank you

[/ code]

For your second result, it will work.

SELECT T1.NO, T1. VAL | «, » || T2. STR. VAL OF

TEST10 T1,

T2 OF TEST10

WHERE T1. VAL<>

AND T1.NO = T2.NO

ORDER BY NOT, STR;

OUTPUT:

1 A, B
1 A, C
1 A, D
1 B, C
1 B, D
1 C, D
2 A, B
3 A, B
3 A, C
3 B, C

Tags: Database

Similar Questions

  • Request to divide the value of the field

    Hi all

    In the employees table, I have data in the column employee_name as follows

    Aaron, Ms. Jamie (Jamie)

    Aaron, Mrs. Jenette (SEDE)

    Abbott, Mrs. Rachel (Rachel)

    Breton, Mr. Jean

    BRITZ, Ms. Sarie (Hervé)

    -> Now I want to display the name of the employee as "Mrs. Jamie" (with out the family name and with some support included text),.

    -> How to achieve this goal by the SQL query. Help me please

    Thanks in advance

    Chantal

    WITH t AS

    (SELECT "Aaron, Ms. Jamie (Jamie)" DOUBLE str)

    UNION ALL

    SELECT "Aaron, Mrs. Jenette (SEDE)" DOUBLE

    UNION ALL

    SELECT "Abbott, Mrs. Rachel (Rachel)" DOUBLE

    UNION ALL

    SELECT 'Breton, Mr. Jean' DOUBLE

    UNION ALL

    SELECT "Britz, Ms. Sarie (Sarie)" DOUBLE)

    Select
    Str
    substr (str

    , instr (str, ' ') + 1

    , decode (instr (str, ' (')))

    0, length (str)

    , instr (str, ' (()) - 2)

    )

    -instr (str, ' ')

    ) str2
    t

    STR STR2
    Aaron, Ms. Jamie (Jamie) Ms. Jamie
    Aaron, Mrs. Jenette (SEDE) Ms. Nicole
    Abbott, Mrs. Rachel (Rachel) Mrs. Rachel
    Breton, Mr. Jean Mr. Jean
    BRITZ, Ms. Sarie (Hervé) Ms. Sarie
  • Divide the values of a single column into multiple values of columns

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

    Table1:

    Col_val Col1, Col2

    Code1 POINT 45

    L2 AB 45

    L1 POINT 45 OF

    Code2 CAB 61

    ABC 51 LABORATORY

    SSS LAB 45

    QQQ BED 123

    BBV COT 100

    FFF COT 444

    Output as expected:

    OUT1 out2 out3-out4, out5

    Code1 AB SSS

    L1

    Code2

    ABC

    QQQ

    BBV

    FFF

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

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

    Hello all, I use Oracle 11.2 of SOE, the value of the variable C is: numberA:numberB for example, C: = ' 1 B: 5 A: 12 has: B: 43 3A ", I have divided than the values of two Variables A and B with the letters of withdrawal and replacement of: for the comma. Namely, the value of each would be: is: 5,12,43 B is: 1.3 someone could help to come up with the correct Exp Reg for this task. Thanks in advance.

    Here's a way (like SQL or PL/SQL):

    with t (Spercu))
    Select "1 B: 5 A: 12 A: B: 43 3A ' double
    )
    Select Spercu
    , regexp_replace (regexp_replace (regexp_replace(strC||':','\d+B:'),' A:$ '), ':', ',') as strA
    , regexp_replace (regexp_replace (regexp_replace(strC||':','\d+A:'),' B:$ '), 'B:', ',') as strB
    ;

    SPERCU STRA, STRB
    ---------------- -------- ------
    1 B: 5 A: 12 A: B: 43 3A 1.3 5,12,43

    or

    declare
    varA varchar2 (30);
    varB varchar2 (30);
    varC varchar2 (30): = ' 1 B: 5 A: 12 A: B: 43 3A;
    Start
    varA: = regexp_replace (regexp_replace (regexp_replace(varC||':','\d+B:'),' A:$ '), ':', ',');
    varB: = regexp_replace (regexp_replace (regexp_replace(varC||':','\d+A:'),' B:$ '), 'B:', ',');
    dbms_output.put_line (Vara);
    dbms_output.put_line (varB);
    end;
    anonymous block filled
    5,12,43
    1, 3

    Replace it after you add a trailing colon varC, Interior removes all the ' nB: "Vara and all the" nA: "from varB. The Middle replace deletes the pair of colon final letter, and replace external converts the other pairs of commas leter-colon.

    Kind regards
    Bob

  • Request to change the values of the parameters of the Prod DB

    Hello

    The App team wants to change the values from DB under two parameters in Prod DB. App team has mentioned that this change was done in QA and verified to work.

    I now want to make the same change in Prod.Could you please confirm if these changes can be made?

    optimizer_index_caching = 0

    OPTIMIZER_INDEX_COST_ADJ = 100

    In addition to this App team wants to rebuild indexes and collect statistics in the same PB.

    Please note that the current values set for these two parameters in the database are as below.

    * .optimizer_index_caching = 99

    * .optimizer_index_cost_adj = 1

    Oracle - 11.2.0.3.0

    OS - Linux 6.6

    It is env Prod.

    It is BONE cluster with two nodes.


    Cordially,

    Bala

    changing this setting will change the way index is used by the optimizer.

    * .optimizer_index_caching = 99--> it is to tell the optimizer that the index values are cached. To force an index scan.

    * .optimizer_index_cost_adj = 1--> the default value of this parameter is 100. If you change the value of this parameter to 1 access the index will give preference by the optimizer. This happens usually when the optimizer is unable to choose and index. To force the use of the index, this setting is changed.

  • request to retrieve the value of the column and use in the other rows of the table

    Hi all

    I have a table where I maintain pairs name / value of a particular job.  Now, I would like to see some of the values of the rows passed to other rows in a table for example

    create job_name_value

    (

    VARCHAR2 (100) job_name,.

    name varchar2 (100),

    value varchar2 (100)

    );

    job_name name value
    TRGJOB% FPATH/ USR/LOCAL/TRGJOB
    TRGJOB% FDATECALDATE + 1
    TRGJOB$FNAME1%%FPATH.mywatchfile1.%FDATE
    TRGJOBFNAME2%%FPATH.mywathcfile2.%FDATE
    TRGJOB% FNAME3%FPATH.mywatchfile3.%FDATE

    can we write a sql query to produce output as below the objective is to use the value of fdate and fpath in the remaining lines. If there is no fdate and fpath then value should return such what or we need to use the stored procedure to achieve

    / usr/local/trgjob/mywatchfile1. CALDATE + 1

    / usr/local/trgjob/mywatchfile2. CALDATE + 1

    / usr/local/trgjob/mywatchfile3. CALDATE + 1

    Hello

    Since it cannot be '% FDATTE' or '% FPATH' (or both) then you need to replace each of them separately.  If the other does not, there 'replacement' will do nothing, but this will not affect the result of the other.

    Here's a way to do it:

    SELECT REPLACE (REPLACE (n.value

    '% FPATH.'

    p.value | '/'

    )

    , '% FDATE '.

    d.value

    ) AS output_value

    OF job_name_value n

    LEFT OUTER JOIN job_name_value p ON p.name = '% f '.

    LEFT OUTER JOIN job_name_value d ON p.name = '% FDATE '.

    WHERE n.name AS '\%FNAME%' ESCAPE ' \'

    ;

    I hope that answers your question.

    If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.

    Report when the above query is to give erroneous results and explain, using specific examples, how to get the correct results of data provided in these places.  If you change the query at all, your postal code.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

  • How do I divide the values in an output of the query?

    I have this code:

    <cfoutput query="GetResults">
      <tr>
      <td nowrap="nowrap">#csedept_name#</td>
      <td nowrap="nowrap">#question_1#</td>
      <td nowrap="nowrap">#question_2#</td>
      <td nowrap="nowrap">#question_3#</td>
      <td nowrap="nowrap">#question_4#</td>
      <td nowrap="nowrap">#question_5#</td>
      <td nowrap="nowrap">(#question_1#/#question_2#)</td>
      </tr>
    

    9 I do not get the answert online I would I actually get the value of question_1 and question_2, something like (5/4). How I'd get him show 1.25?

    Change to line 9 to:

    (question_1 # / question_2 #)

    -Carl V.

  • How do I divide the values from the cfselect which allows multiple?

    I have a basic form with a drop-down box and a cfselect box which allows the user to select multiples. For each element selected in the cfselect box, I need to fill in a line in the database. How do I "split" the values of the cfselect and fill several lines in the database?

    Found a large sample... and it works fine now... http://KB.Adobe.com/selfservice/viewContent.do?externalId=tn_17007



    INSERT INTO tContentLinks (ContentID, SubSectionID)
    VALUES (' #Form.ContentID # ', ' #SubSectionID # ')

  • divide the value in the column value

    Hi all

    I have an EMP table with column (NAME varchar2 (100)). It has a full name with name value "«MIDDLE_NAME"»
    It should always has 3 words value separated by single spaces.

    Value of the sample: FRANKLIN ROOSEVELT OBAMA


    I want to create a view EMP2_VW that contains a split each distinct names as MIDDLE_NAME, LAST_NAME, FIRST_NAME


    How can I do this?


    Thank you very much
    SQL> with t as (
      2  select 'FRANKLIN ROOSEVELT OBAMA' fullname from dual
      3  )
      4  --
      5  -- actual query:
      6  --
      7  select fullname
      8  ,      substr( fullname
      9               , 1
     10               , instr(fullname, chr(32))-1
     11               ) first_name
     12  ,      substr( fullname
     13               , instr(fullname, chr(32), 1, 1)+1
     14               , instr(fullname, chr(32), 1, 2)-1 - instr(fullname, chr(32), 1, 1)
     15               ) middle_name
     16  ,      substr( fullname
     17               , instr(fullname, chr(32), 1, 2)+1
     18               ) last_name
     19  from   t;
    
    FULLNAME                 FIRST_NAME               MIDDLE_NAME              LAST_NAME
    ------------------------ ------------------------ ------------------------ -------------
    FRANKLIN ROOSEVELT OBAMA FRANKLIN                 ROOSEVELT                OBAMA
    
    1 row selected.
    
  • Divide the value and insert into the table

    create table mytab (a tank (25), b Varchar2 (50), Varchar2 (100)) C;

    I have a string like

    myStr:'A$bggoy#qwewewee@A$Qwe#zcxdf@A$po#xvcvxc@A$sdmy#sfdsdf @'

    I need to divide and insert into mytab

    That's what I tried

    declare p_str varchar2 (4000)

    Begin

    long l_str p_str default. '$';

    number of l_n;

    myTableType l_data: = myTabletype();

    Start

    loop

    l_n: = instr (l_str, ",");

    When the output (nvl(l_n,0) = 0);

    l_data.extend;

    l_data (l_data.count): =.

    LTRIM (rtrim (substr (l_str, 1, l_n - 1)));

    l_str: = substr (l_str, l_n + 1);

    -Connect mytab

    end loop;

    end;

    Shows below inf-s:

    describe the OBJ_SPLIT ;

    recreate

    CREATE OR REPLACE TYPE OBJ_SPLIT_table IS TABLE OF OBJ_SPLIT;

    to view the result of the compilation

    CREATE OR REPLACE Function Fn_get_split (P_str VARCHAR2)

    return OBJ_SPLIT_table

    PIPELINED is type t_ref_cursor IS REF CURSOR;

    rf_c t_ref_cursor;

    r_out_rec OBJ_SPLIT: = OBJ_SPLIT (null, null, null, null);

    Begin

    Open the rf_c for

    Select s,.

    REGEXP_SUBSTR (str, ' [^ $] +', 1, 1) s1,

    REGEXP_SUBSTR (str, ' [^ $#] +', 1, 2) s2,.

    REGEXP_SUBSTR (str, ' [^ $#] +' 1, 3) s3

    from (select s, REGEXP_SUBSTR (s, "[^ @] +', 1, rownum") str)

    (select s P_str of double)

    connect by instr (s, ' @', 1, level - 1) > 0)

    where str is not null;

    LOOP

    EXTRACTION rf_c

    IN

    r_out_rec. Str,

    r_out_rec. Delimter1,

    r_out_rec. Delimter2,

    r_out_rec. Delimter3;

    EXIT WHEN rf_c % NOTFOUND;

    PIPE ROW (r_out_rec);

    END LOOP;

    CLOSE Rf_c;

    end;

    and the result

    Select DELIMTER1, DELIMTER2, table DELIMTER3 (Fn_get_split('A$bggoy#qwewewee@A$qwe#zcxdf@A$po#xvcvxc@A$sdmy#sfdsdf@'));

    in SQLPLUS


    ----

    Ramin Hashimzade

  • How to format a single cell based on the value in another cell?

    IM using JDEV 11.1.2.4 and had the following use cases.

    based on a threshold value in a column of my line, I want to show a different value in the color red.

    How to get there?

    Hello

    This could be a possible solution using inlineStyle and a simple logic of EL

    inlineStyle = ' #{rank. " TRESHOLD > 10? "{" color: #990000 ': "color: #000000 '} '.

    ID = "ot1" / >

    Marc

  • Divide the value of the textfield in 2 parts and put each part var

    I have a textfield, which has a text value: Paris France. Now I need to know how I can take this string, cut it into 2 parts (France and Paris) and put them into two parts in a var. So:

    < textfield id = 'field1' text = 'Paris, France' >

    and somewhere, I should get

    var1 = France;

    var2 = Paris;

    I know there is a separating string command, but I'm not familiar with one of these things.

    Thanks for your help!

    first place to try is the ActionScript document library - google works as well

    in the meantime, something like this will probably work.

    var strArray:Array = field1.text.split(' ');
    var var1:String = strArray(0);
    var var2:String = strArray(1);
    
  • Concatenate 2 data fields and the values on the same line

    Hello

    I'm pretty new to BI Publisher. I want to concatenate 2 data (product and ProductType) fields. These concatenated values so I want to put them on a single line.
    for example.
    the values should look like

    ProductType1.Product1, ProductType2.Product2, ProductType3.Product3...

    Thank you.

    Check the forum thread
    Re: Display of horizontal lines
    for a similar request.

    If you still face questions send your sample xml and rtf

  • Formula for dividing the three entries from field (D = A/B/C)

    I have a formula to get a value, and this is to divide the three entries from field. I don't know enough about javascript to correctly enter the code to make this happen. I have 20 rows in a form and I need to calculate column D I saw a thread on how to divide the two fields, but I need to go further with it. Can someone help me? I added that I was working (left) and I tried to develop (right).

    Internet Personal

    establish the variables for the names of fields for the dividend and the divisor.

    var sDividend = ' domain name my dividends. "

    var sDivisor = 'name of the My divisor field. "

    get the value of the divisor field

    var nDivisor = this.getField ("sDivisor") .value;

    get the value of the dividend field

    var nDividend = this.getField('sDividend').vlalue;

    do not modify the code under this line

    Clear the value of the result field

    Event.value = ";

    see if we have a divisor of zero

    If (nDivisor! = 0) {}

    We can then divide

    Event.Value = nDividend / nDivisor;

    } / / end of calculation of the division

    The above assumes that you are dividing the value of the 2 fields.

    Assignment of the variables

    var PW1 = "PlotWt1";

    var WBC1 = "WetbuConversion1";

    var AF1 = "Acre Factor1";

    Get the values

    var nPW1 = this.getField (PW1) .value;

    var nWBC1 = this.getField ("WBC1") .value;

    FNa1 var = this.getField (AF1) .value;

    Clear the value of the result field

    Event.Value ="";

    see if we have a divisor of zero

    If (nWBC1! = 0) {}

    //Actual division operation

    event.value = nPW1 / nWBC1 / FNa1;

    } / / end of the calculation of the division

    Change the line of code:

    If (nWBC1! = 0 & nAFN! = 0) {}

    If you want to use the same calculation for a number of lines, you can create a function that all calculated fields can use, but it depends on the names of the fields that you use. If you are simply changing the number at the end, the function might be:

    function calc1(num) {
    
        // Assigning the variables
        var PW = "PlotWt" + num;
        var WBC = "WetbuConversion" + num;
        var AF = "AcreFactor1" + num;
    
        // Getting the values
        var nPW = this.getField(PW).value;
        var nWBC = this.getField(WBC).value;
        var nAF = this.getField(AF).value;
    
        // clear the result field value
        event.value="";
    
        // see if we have a non-zero divisor
        if (nWBC !=0 && nAF != 0) {
            //Actual division operation
            event.value = nPW / nWBC / nAF;
        }
    
    }
    

    You can then call it in the custom calculation of the field as the script:

    Calc1 (1);  Rank 1

    For line #5, it would be:

    Calc1 (5);  Rank 5

    This could be simplified a bit if you have changed your domain naming scheme to make it easier to extract the line number. In this way, that you wouldn't have to pass as I showed.

    To create a script at the level of the document to place the function, select: Advanced > Document Processing > Document JavaScripts > Add

  • What are the values of the State of Session State?

    No one knows what the I, R and U values in the status column for the status of Session screen average?

    Can't seem to find any documentation about them.

    For a given page or element of the request:

    Inserted - the value is stored in the table of session state for the first time in the session.

    Update: the value that was already in the table of session state has acquired a new value.

    Reset - the value that was already in the session state table is changed to null using a clear-cache event.

    Scott

Maybe you are looking for

  • received emails

    At least 10 times a day, I get duplicate emails that were originally downloaded this morning or even a day or two before. I tried to delete the file popstat. I downloaded the add-on "remove duplicate email" and I checked that my anti-virus analyze th

  • Cannot access EA3500

    I will summarize my previous post of excessive length on this topic: I am talking to someone through the connection to a telephone ea3500 admin page. 2 computers using separate windows 8, either wired or wireless, the router accepts a local login pas

  • HP dv4 1551dx does hardware support for virtualization?

    Hello HP dv4 1551dx does hardware support for virtualization? If support, how it allows? Thank you

  • Issue of TMSXE - cohabitation of server deployment?

    I couldn't find, even though I fully acknowledge I may have missed in the installation guide, I have a question about the feasibility of the TMSXE installation on the same server as the application of TMS. I know that on page 9, the guide says that C

  • How to migrate code from one environment to another in the MFT 12 c

    Hi allHow to migrate code from one environment to another in the MFT 12 c.Thank you and best regards,Tilquin.