decode the statement with. «, » ||

Hello
I have the requriement next where I need to join the 2 numbers with comma inside the decode stmt
create table  A_STY_VON ( C_1_ID number ,C_2_ID number ,C_3_ID number)

Insert into A_STY_VON
   (C_1_ID, C_2_ID, C_3_ID)
 Values
   (1, 2, 3);
Insert into A_STY_VON
   (C_1_ID, C_3_ID)
 Values
   (1, 3);
Insert into A_STY_VON
   (C_1_ID, C_2_ID)
 Values
   (1, 2);
Insert into A_STY_VON
   (C_2_ID, C_3_ID)
 Values
   (2, 3);
And the following select stmt does not work
SELECT   DECODE (
          A.C_3_ID,
          NULL, DECODE (A.C_2_ID,
                        NULL, A.C_1_ID,
                        A.C_1_ID || A.C_2_ID) ,
             A.C_1_ID
         || A.C_2_ID
         || A.C_3_Id) dcd
  FROM A_STY_VON A 
But I want the comma between the numbers so I tried the following (with separate)
where I get the error invalid number
SELECT  distinct DECODE (
          A.C_3_ID,
          NULL, DECODE (A.C_2_ID,
                        NULL, A.C_1_ID,
                        A.C_1_ID ||','|| A.C_2_ID) ,
             A.C_1_ID
          ||','|| A.C_2_ID
          ||','|| A.C_3_Id) dcd
  FROM A_STY_VON A 
Could you please help me to achieve this

Thank you

Published by: Smile on April 26, 2012 03:50

A rough solution will add to_char everywhere.

SELECT  distinct DECODE (
          to_char(A.C_3_ID),
          NULL, DECODE (to_char(A.C_2_ID),
                        NULL, to_char(A.C_1_ID),
                        to_char(A.C_1_ID) ||','|| to_char(A.C_2_ID)) ,
             to_char(A.C_1_ID)
          ||','|| to_char(A.C_2_ID)
          ||','|| to_char(A.C_3_Id)) dcd
  FROM A_STY_VON A

Tags: Database

Similar Questions

  • Decode the statement using the nvl function

    I inherited the code uses a decode and nvl. I'm not sure the purpose of him and wants confirmation that it is logical and an error. The situation can be re-created by implementing the following.

    CREATE TABLE XX_TEST
    (IDENTIFICATION NUMBER,
    DOMAIN VARCHAR2 (255)
    )

    INSERT INTO XX_TEST (ID, FIELD) VALUES (1, 'Yes')
    INSERT INTO XX_TEST (ID, FIELD) VALUES (2, 'No')
    INSERT INTO XX_TEST (ID, FIELD) VALUES (3, NULL)

    Commit

    SELECT ID,
    FIELD,
    DECODE (on the GROUND, the 'yes', ' Yes result this ", NVL (FIELD, 'No'),"no results don't do this","catch all result do this")
    OF XX_TEST

    I'm not sure of the NVL (FIELD, 'No') I think that the creator may have thought this would draw the NULL values, but it is not.
    Null is not converted into no. and plunges into the place the Tote. Can anyone help with an explanation of how oracle is interpretting the select statement. Any ideas on why NVL would be used like that? Seems a mistake?

    decode compares them the first FIELD against NVL (FIELD, 'No').
    If the FIELD is null estimated them VSN none which is not null, then...
    just to make an entry for the null value and one for the 'no' with the same result.
    However, I prefer case statement in this case.

    SELECT ID,
    FIELD,
    case
    when FIELD ='Yes' then 'Yes Result do this'
    when FIELD is null or FIELD = 'No' THen 'No result do this'
    else 'catch all result do this'
    end
    FROM XX_TEST
    

    As more readable.
    concerning

  • How to create a button in the State with two different images?

    What I mean is... I have a picture that is conveyed as a button that has not been pressed, and I also have an image that expresses the same key but this time it is pressed. Is there a way to ensure that when the button is normal I seized the image of the button upward and then make sure that when I roll on or press the Enter key, the image of the button down?

    Thank you, Ben Charter

    Hi Ben,

    Just create a Menu and with the Normal State is selected, use the fill options to fill an image in the Menu item. Select the rollover / the mouse to the bottom of the State in the States Panel, then assign an image by using the options to fill again. This is a swap of base image using normals and States of Muse down mice.

    Kind regards

    Akshay

  • include the component in the State with AS3

    Hi I have a tab navigator that I instantiated in my AS3 code.  I want to make this browser tab display only in some countries, but not all. How can I do this?  Obviously with mxml I can add a property 'includeIn' and assign which has it should be visible, but how would I do this in ActionScript?   Thank you, fuyuko

    The States are a concept MXML, not a concept of ACEs. In AS, you would use what logic allows you to change your status, and then do the things you want to happen next.

    override public function set currentState(value:String):void

    {

    super.currentState = value;

    do things with a bunch of instructions conditional mess

    }

    The above doesn't look natural.

    If you are interesting in creating features like State in AS native, you can look in the Model of Memento.

  • decode the problem with dates in APEX

    In oracle, I can run this

    Select decode (CBT_DT, to_date (January 1, 2100 ',' DD/MM/YYYY '), null, CBT_DT) CBT_DT
    of DMN_USER_LIST_PORTAL

    and it works.

    but in the APEX, he wants to remove date column and make it a character.
    Help, please
    Thank you
    Doug

    Perhaps rewrite with a CASE statement can help? Or a cast of the explicit NULL value to a date.

    select case
            when cbt_dt = to_date('01/01/2100', 'MM/DD/YYYY') then to_date(NULL)
            else  cbt_dt
            end
    from DMN_USER_LIST_PORTAL 
    
  • Decode the statement inside the box

    Can we use Decode statement inside a CASE statement as below - show

    It gives an error - the better to write with any error

    create or replace
    test run (a varchar2) RETURN VARCHAR2
    is
    m varchar2 (20);
    Start
    m : =
    CASE
    WHEN a (IN)
    '1009 '-(soon obsolete)
    "1010"
    , ' 1019 "
    '1051'
    , "XGP.
    "XSC")
    (SELECT DECODE(v_lef_cd,'NAM','71','GLB','99','01') in the of THE DOUBLE m)
    (-) THEN '01' - UNITED STATES
    WHEN a (IN)
    ' 1069' - South Africa
    , "SAO" - South Africa
    , 'HIS' - South Africa
    ) THEN '26' - South Africa

    ANOTHER NULL
    END;
    return m;
    end;

    Hello

    user575932 wrote:
    Thanks for your reply... I would be happy if my problem is completely resolved

    In the code below in the ELSE part... (When the value NULL is written) I have check for more condition using IF/ELSE or DECODE...

    SQL > l
    1 DECLARE
    v_var1 2 VARCHAR2 (20);
    3 model VARCHAR2 (20): = 'X '.
    4 BEGIN
    v_var1 5: = dummy BOX WHEN ('X', 'y')
    6 THEN CASE model WHEN = 'X' THEN 'HELLO WORLD '.
    7. OTHER SIDE (_ NULL);
    8 DBMS_OUTPUT. Put_line (v_var1);
    9 END;
    10.

    Sorry, it's impossible. You cannot place the executable statements in PL/SQL (as IF...) ELSE or SELECT... INTO) in the middle of the CASE expression.

    You can get some desired using the results
    (1) IF... Else constantly, instead of CASE (this would allow you to do a SELECT... If you really want to use DECODE INTO), or
    (2) nested CASE expressions, as I showed above, or by
    (3) reformulating the expression BOX so it shouldn't be a nested DECODE or CASE, as I showed earlier

  • Decode the statement


    Hello

    The following data are in table

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    [email protected]

    I am writing the script to retrieve the data above with the name starts with 'nn' %et n@nhellas email ID but the data recover some of them affter execution. Kindly help me how to change the script based on the above

    SELECT DISTINCT P_EMAIL, A.FLAG, A.POL_AGENT_CODE, A.YPOKATASTHMA

    OF TMP_AIGGRIT_DC024 A, PM_CODES

    WHERE PC_CODE = A.YPOKATASTHMA (+)

    - AND A.P_EMAIL = PC_LONG_DESC

    - AND A.SESSION_ID =: HEADER. SESSION_ID

    AND A.FLAG! = 0

    AND P_EMAIL! = "¿¿¿Email".

    AND A.POL_AGENT_CODE BETWEEN: P_FM_AGNT AND: P_TO_AGNT

    AND A.YPOKATASTHMA BETWEEN: P_YPOKATASTHMA_FM AND: P_YPOKATASTHMA_TO

    AND DECODE (A.POL_AGENT_CODE, 'B0000610',

    DECODE (P_EMAIL,' [email protected]', SUBSTR(P_EMAIL,3,3), YPOKATASTHMA),

    SUBSTR (P_EMAIL, 3, 3)) = SUBSTR (P_EMAIL, 3, 3);

    You mean

    ....

    and ((a.pol_agent_code = «B0000610» et (p_email comme ' %@nnadvisors.gr' ou p_email comme ' %@nnhellas.gr')))

    or (a.pol_agent_code! = 'B0000610' and p_email not as ' %@nnadvisors.gr' and p_email not as ' %@nnhellas.gr')

    )

  • Remove the statement with subquery with more than 1 columns

    Hi all

    I want to delete the data in the kpi_logs table for which the kpi_def_id column is less than the max (timestamp). The timestamp is the date data type. I wrote below query but its throwing an error as an SQL error: ORA-00936: lack of expression.

    DELETE FROM KPI_LOGS WHERE (Select MAX (TIMESTAMP), KPI_DEF_ID of the KPI_DEF_ID KPI_LOGS GROUP);

    Hello

    user12251389 wrote:

    I want to delete the data in the kpi_logs table for which the kpi_def_id column is less than the max (timestamp). The timestamp is the date data type. I wrote below query but its throwing an error as an SQL error: ORA-00936: lack of expression.

    DELETE FROM KPI_LOGS WHERE (Select MAX (TIMESTAMP), KPI_DEF_ID of the KPI_DEF_ID KPI_LOGS GROUP);

    Whenever you have a question, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the accurate results you want from this data, so that people who want to help you can recreate the problem and test their ideas.

    If you ask about a DML operation, such as DELETE, and INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.

    Explain, using specific examples, how you get these results from these data.

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

    See the FAQ forum:

    You want to keep only the maximum timestamp for the entire table, or you want the maximum timestamp for each distinct value of kpi_def_id?

    If it is just the maximum timestamp for the whole picture, then

    DELETE FROM kpi_logs

    WHERE the timestamp<>

    SELECT MAX (timestamp)

    OF kpi_logs

    );

    If you want to keep the maximum timestamp for each individual value phew kpi_def_id, then:

    DELETE FROM kpi_logs

    WHERE (kpi_def_id, timestamp NOT IN)

    SELECT kpi_def_id

    MAX (timestamp)

    OF kpi_logs

    GROUP BY kpi_def_id

    );

    assuming that no column can be NULL.

    Moreover, the TIMESTAMP is a data type, similar to this DAY.  You'll only cause confusion by saying it is a type of data when it is really another.  In addition, TIMESTAMP is a keyword from Oracle, is not a very good column name.  Why not give your column a name more meaningful, accurate, such as create_date or entry_dt?

  • Insert the statement with &amp; in the chain

    Hello

    When you use the insert in varchar2 column having below value, it's the slightest mistake out.
    But, if I remove & symbol... It's inclusion.
    suggestions to insert any string

    "Networking - Cisco SMARTnet-6600 | Security & Switch Service Cont-6620 | Not used-0000"

    Thank you

    use

    SET DEFINE OFF

    before the insert statement.

    Concerning
    Arun

  • Help looping of the States with a timer

    When the timer goes off I need to move to the next State.  Y at - it an easy way to tell it to go to the next State or what I need to determine the current state and set the next State?

    If I go the second route how would - this code be?

    private void onTimer(evt:TimerEvent):void
    {
    If (currentState is "life sciences")

    <!-How can I say this 'lifestyle' the new State do? ->
    }

    except "this.states" every thing must be your custom name (myStates)... I'm tlking on the next line... Sorry for writing the code so confused...

    if(States == null) States = this.states;

  • Remove the statement with a subquery

    Hi Experts,
    I currently have a select query with subquerys, I want to turn it into a deletion request.
    select cy.lmp, cy.dt from 
    
    (SELECT LMP, CHANGE_SD, ADD_MONTHS(DT,12) AS DT 
    FROM FORECAST WHERE EVENT = 'GROWTH RATE') ny --next year,
    
    (SELECT LMP, CHANGE_SD,  DT 
    FROM FORECAST WHERE EVENT = 'GROWTH RATE') cy -- current year
    
    where ny.change_sd = cy.change_sd and ny.dt = cy.dt and ny.lmp = cy.lmp
    order by cy.lmp;
    Here, I want to delete rows from the table the forecasts which are the result of the select query above.

    Your help is appreciated.

    Hello

    Will there be matching columns in the forecast table?
    If so, you can do this:

    DELETE  forecast
    WHERE   (column_a, column_b) IN
    (SELECT  cy.lmp,   cy.dt
     FROM    ...     -- rest of query (except ORDER BY clause) goes here
    );
    
  • WHERE condition has decoded the statement

    Hi all

    I have a requirement to have two or three conditions based on a condition in the WHERE clause. Please do the needful. Thank you.

    If the context value is PROJECTS BILLS, then must have conditons

    (due_date-nvl(rt.printing_lead_days,31)) < sysdate
    and aps.customer_trx_id = rct.customer_trx_id
    and rt.term_id (+) = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id
    of ra_customer_trx_all
    where trx_number =
    (: $FLEX$ .AR_RAXINV_TRX_NUMBER)

    If the context value is other than the PROJECT INVOICES, the

    (aps.customer_trx_id = rct.customer_trx_id
    and rt.term_id (+) = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id
    of ra_customer_trx_all
    where trx_number =
    (: $FLEX$ .AR_RAXINV_TRX_NUMBER)


    Ex:

    I tried, but received the error.

    Select terms_sequence_number
    ar_payment_schedules_all aps, RA_CUSTOMER_TRX_ALL CTN, ra_terms rt
    where
    DECODE (rct.interface_header_context,'PROJECTS BILLS, (aps.customer_trx_id = rct.customer_trx_id)
    and rt.term_id (+) = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id
    of ra_customer_trx_all
    where trx_number = '80000062')),
    ((due_date-nvl(rt.printing_lead_days,31)) < sysdate and)
    APS.customer_trx_id = rct.customer_trx_id
    and rt.term_id (+) = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id
    of ra_customer_trx_all
    where trx_number = '80000062')))

    Thank you
    Abdul

    Select...
    Of...
    where (rct.interface_header_context = 'INVOICES of PROJECTS'
    OR (rct.interface_header_context! = "PROJECTS BILLS" and (due_date-nvl(rt.printing_lead_days,31))
    )< sysdate="">
    and aps.customer_trx_id = rct.customer_trx_id
    and rt.term_id = rct.term_id
    and aps.customer_trx_id = (select customer_trx_id from the ra_customer_trx_all where trx_number = '80000062')

  • management of the State with audio buzz.js

    Hey guys,.

    Been researching threads and can't find the answer!  I really try to not ask until it is the last resort.

    I need to find a way to stop the sound and symbol that plays when I click on another.

    This will help me in all my projects!  Please someone help me.

    composition ready, I have the sounds listed as such:

    mediaPath var = "soundz";

    sym.iSound1 = new buzz.sound ("soundz/toilets", {format: ["mp3"]});

    sym.iSound1.bind ('loadeddata', Function {}

    var point = Edge.getComposition (compId) .getStage ();

    });

    sym.iSound2 = new buzz.sound ("soundz/coffee", {format: ["mp3"]});

    sym.iSound2.bind ('loadeddata', Function {}

    var point = Edge.getComposition (compId) .getStage ();

    });

    each button, I have this:

    sym.getComposition () .getStage ().iSound1.play ();

    var mySymbolObject = sym.getSymbol ("top1");

    mySymbolObject.play ();

    Help, please!  I know how to stop a sound. But there are 10 total sounds. I could just list code to stop the other 9 sounds on each button?  Seems redundant.

    That is to say

    sym.getComposition () .getStage ().iSound1.stop ();

    sym.getComposition () .getStage ().iSound2.stop ();

    sym.getComposition () .getStage ().iSound3.stop ();

    etc etc.

    var mySymbolObject = sym.getSymbol ("top1");

    mySymbolObject.play ();

    And here are the project files...


    https://www.dropbox.com/sh/daws4h9yvgkwxg4/fnUerNx6Sl

    Here is your file corrected. All the code is compositionReady. I also added the ogg files for compatibility. I do not thing you need of aif, but I went on. Remove them and try. Using a table for your symbols simplifies the code and this way, they can have any name.

    https://app.box.com/s/ne6llgfln3sgqtgdpbfo

  • If the statement with frames

    Let's say I have 3 buttons.

    Each button goToAndPlays an image in a clip.


    Now let's say that in this configuration there is an other installer like him.

    Basically; If the user clicks button1 the helmet_mc goes to frame 2

    as I reached in

    yellow1_btn.onRelease = function() {}
    helmet_mc.gotoAndStop (2);


    Here's where I'm stuck.

    I'm looking for the right ' if else ' here's the pseudo-code


    How can I program it; If helmet_mc is on frame 2,

    then the 4 button when clicked helmet_mc goes to the frame 5.

    then 5 when the user clicks the button of helmet_mc g oes to the 6 framework,

    then the 6 button when clicked helmet_mc goes to the 7 framework.


    AS2 is rarely good in pointing to the real problem.  In the code I provided and the ciode show you, there is a missing brace...

    If (helmet_mc._currentframe == 2) {}<-- that="">

  • Insert the statement with the subquery to insert several lines

    Hi friends,

    Please find below mentioned query and error. Also suggest me to go forward.

    SQL > INSERT INTO FM_TRAN_DOC_NO (TDOC_COMP_CODE,

    2 TDOC_TRAN_CODE,

    TDOC_ACNT_YEAR 3,.

    TDOC_CUR_NO 4,.

    TDOC_MAX_NO 5,.

    TDOC_CAL_YEAR 6,.

    TDOC_PERIOD 7,.

    TDOC_DIVN_CODE 8,.

    TDOC_DEPT_CODE 9,.

    TDOC_CR_UID 10,

    TDOC_CR_DT 11,

    TDOC_UPD_UID 12,

    13 TDOC_UPD_DT)

    14 SELECT '001',

    15 (SELECT DISTINCT FM_TRAN_DOC_NO TDOC_TRAN_CODE

    16               '6',

    17               '0',

    18 '9999',

    19 NULL,

    20 NULL,

    21 NULL,

    22 NULL,

    23 "AGT,"

    24 TO_DATE (SYSDATE),

    25 NULL,

    26 TO_DATE (SYSDATE) FROM DUAL;

    (SELECT DISTINCT FM_TRAN_DOC_NO TDOC_TRAN_CODE),

    *

    ERROR on line 15:

    ORA-01427: einreihig subquery returns multiple rows

    +Untested.

    When values except 'TDOC_TRAN_CODE' are hardcoded, there is no need to select double.

    Something like that?

    INSERT INTO FM_TRAN_DOC_NO)

    TDOC_COMP_CODE,

    TDOC_TRAN_CODE,

    TDOC_ACNT_YEAR,

    TDOC_CUR_NO,

    TDOC_MAX_NO,

    TDOC_CAL_YEAR,

    TDOC_PERIOD,

    TDOC_DIVN_CODE,

    TDOC_DEPT_CODE,

    TDOC_CR_UID,

    TDOC_CR_DT,

    TDOC_UPD_UID,

    TDOC_UPD_DT

    )

    SELECT DISTINCT

    '001',

    TDOC_TRAN_CODE,

    « 6 »,

    '0',

    "9999",

    NULL,

    NULL,

    NULL,

    NULL,

    "AGT,"

    TO_DATE (SYSDATE),

    NULL,

    TO_DATE (SYSDATE)

    OF FM_TRAN_DOC_NO;

Maybe you are looking for

  • Why my site Iframe is partially loading?

    Dear Sir. IFRAME of my Web site loads partially in firefox, but to load entirely in chrome. You can check http://orthocad.IITB.AC.in/betic/ Please let me know what needs to be done to solve this problem.

  • How can I delete a bookmark for a Web site that no longer exists?

    A site that I go to has completely changed. As a result, their old site no longer exists and they now have a completely new. How can I remove the bookmark for their old site that no longer exists?

  • How to sort the rows according to the contents in cells

    Hello Is it possible to use a formula to sort the rows according to their cell contents? I will include a screenshot of my table. What I want to do is group together people based on where they live. I wish that all rows with an 'x' in a certain State

  • playback without white

    the sansa disk + support, but mine froze on me and sandisk offer to replace it with either a model of sport or jam. I just need to know 100% if playback is supported on the jam.

  • Cannot install the all-in-one printer

    Download HP officejet 4500 G510-m from HP website. When I click on install, I get the HP message: the system cannot find the specified file. I've never had this installation problem.  I could always install. I believe the download is corrupted System