CONCATENATE fields

Hello

I want to concatenate a string based on 3 fields. The concatenation must rest only when the field contains data

create table (test)

Identification number,

Product1 varchar2 (8).

Product2 varchar2 (8).

Product3 varchar2 (8)

)

Insert test values (001, 'car', 'Bike', "CB-HO");

Insert test values (001, 'Car', ","TR-HO");

Insert test values (001, ",", "CB-HO");

Insert test values (002, ",", ");

Insert test values (002, ","Car", are - HO');

output e.g.

001 'car, bike, CB-HO. "

001 'car, TR-HO. "

001 "CB-HO."

002 "

I have tried original the following: select case-sensitive when product1 is not null then product1. case product2 when "then" somewhere else "," | end leader2. case product3 when "then" somewhere else "," | Product3 end end string_test of the test

This always separate by comma null values

Hello

Here's one way:

SELECT id

product1 | NVL2 (product1, ",", NULL).

Product2. NVL2 (product2, ",", NULL).

Product3 AS product_list

OF the test

;

Tags: Database

Similar Questions

  • concatenate fields using commas

    How to concatenate fields using correct English separators? I use Acrobat X Pro.

    I have fields named Field1, Field2, Field3, Field4 and result.

    Example 1

    In Field1, I returned from apples. In Field2, Oranges. The other two fields are empty (Null).

    In the result field, it returns "Apples and Oranges."

    Example 2

    I add grapes field3.

    Returns the result field, 'Apples, Oranges and grapes.'

    Example 3

    I add the pears in Field4.

    The result should be, 'Apples, Oranges, grapes and pears.'

    Any help is appreciated.

    Using hierarchical fields:

    document-level functions;
    function NotNull (element) {}
    filter the stirngs null;
    return String (item) .length > 0;
    }

    function Array2String (aValues) {}
    convert an array of values in decimal delemited string with "and" according to needs;
    aValues = aValues.filter (NotNull); remove null items;
    If (aValues.length > 1) {}
    Add 'and' the last element if more than 1 item in array;
    aValues [aValues.length - 1] = "and" + aValues [aValues.length - 1];
    }
    cString var;
    {Switch (true)}
    value according to the number of items;
    If (aValues.length == 1):
    article 1 - article only;
    cString aValues = [0] + ".";
    break;
    If (aValues.length == 2):
    2 items - no comas;
    cString = aValues.join("") + ".";
    break;
    If (aValues.length > 2):
    comas 3 or more;
    cString = aValues.join (",") + ".";
    break;
    DEFAULT:
    for any item;
    cString = "";
    break;
    }
    return cString;
    }
    end of document-level functions;

    script for calculating customized for result field;
    oField var = this.getField ("item"); get the upper area;
    achildren var = oField.getArray (); bring the kids fields;
    var aValues = new Array(); Array of values;
    for (var i = 0; i)< achildren.length;="" i++)="">
    aValues.push (aChildren [i] .valueAsString); Table filling with values;
    }
    Event.Value = Array2String (aValues);
    end of custom calculation script;

    The script requires no contiguous entries and is scalable for more or less fields without having to edit the script. Document-level functions could be reused in other fields in the form as needed.

    A link to the sample file list concatenate Acrobat.com shared - files

  • CONCATENATE fields and line to transform column

    Hello

    I need to concatenate part_cd with part_nam and run a line of column transformation. I need to do this by using SQL. The sample input and expected output are lower than

    Entry:
    ======
    ord_id part_cd Part_nam
    1 100 AAA
    1 101 BBB
    1 102 CCC
    2 200 XXX
    2 201 YYY

    Output
    ========
    1 100AAA, 101BBB, 102CCC
    2 200XXX, 201YYY


    Thank you for your help in advance

    Rambeau wrote:
    SELECT ord_id, wm_concat(part_cd ||) Part_nam) AS detal
    OF >
    GROUP BY ord_id;

    Please do not recommend the use of wm_concat. This is an undocumented feature and functionality may change in future versions. The use of it can make your application not supported by Oracle.

    Manon,

    You have not specified the version of your database.

    If you are on 10g you can do something like this...

    SQL> col output format a50
    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select 1 as ord_id, 100 as part_cd, 'AAA' as Part_nam from dual union all
      2             select 1, 101, 'BBB' from dual union all
      3             select 1, 102, 'CCC' from dual union all
      4             select 2, 200, 'XXX' from dual union all
      5             select 2, 201, 'YYY' from dual)
      6  --
      7  -- end of test data
      8  --
      9  select ord_id, ltrim(sys_connect_by_path(to_char(part_cd)||part_nam,','),',') as output
     10  from (select ord_id, part_cd, part_nam
     11              ,row_number() over (partition by ord_id order by part_cd) as rn
     12        from t)
     13  where connect_by_isleaf = 1
     14  connect by ord_id = prior ord_id and rn = prior rn+1
     15  start with rn = 1
     16* order by ord_id
    SQL> /
    
        ORD_ID OUTPUT
    ---------- --------------------------------------------------
             1 100AAA,101BBB,102CCC
             2 200XXX,201YYY
    
    SQL>
    

    If you're on 11g, you can watch the new LISTAGG function...

    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/functions089.htm#SQLRF30030

  • SQL to communicate with two rows in one record

    I have a source table that includes data in the following format.
    CON_ADDR_ID TIME_CONFIGURATION START_TM END_TM
    1 GU-798 Tuesday 1/1/1980 08:00 1980-01-01 17:00
    1 GU-798 Thursday 1/1/1980 07:00 01/01/1980 16:00

    I need to concatenate fields time_configuration, start_tm, end_tm for con_addr even

    For example, for the light of the foregoing, the output should be * & you = 480, 1020 & th = 480, 1020 *.

    Logic: -.

    1 convert the time in minutes
    Min start time = 8 h = 480 min
    End time in minutes = 17 h = 1020 mins
    Beginning in minutes hour = 7 h = 420 min
    Time in minutes to end = 16 h = 960 minutes

    2 concatenate 2 rows and 3 columns.
    & < Start the day in format MM > = < start in a few minutes time >, < time in minutes left > & < start the day in format MM > = < start in a few minutes time >, < time in minutes to go >

    user10566312 wrote:
    I have a source table that includes data in the following format.
    CON_ADDR_ID TIME_CONFIGURATION START_TM END_TM
    1 GU-798 Tuesday 1/1/1980 08:00 1980-01-01 17:00
    1 GU-798 Thursday 1/1/1980 07:00 01/01/1980 16:00

    I need to concatenate fields time_configuration, start_tm, end_tm for con_addr even

    For example, for the light of the foregoing, the output should be * & you = 480, 1020 & th = 480, 1020 *.

    Logic: -.

    1 convert the time in minutes
    Min start time = 8 h = 480 min
    End time in minutes = 17 h = 1020 mins
    Beginning in minutes hour = 7 h = 420 min
    Time in minutes to end = 16 h = 960 minutes

    2 concatenate 2 rows and 3 columns.
    &=, &=,

    According to your logic, shouldn't be out & you = 480, 1020 * & th = 420 960 *?

    Can be:

    SQL> ed
    Wrote file afiedt.buf
    
      1  with sample_data
      2       as (select '1-GU-798'
      3                  con_addr_id,
      4                  'Tuesday'
      5                  start_day,
      6                  to_date('1/1/1980 8:00:00 AM', 'DD/MM/YYYY HH12:MI:SS AM')
      7                  start_tm,
      8                  to_date('1/1/1980 5:00:00 PM', 'DD/MM/YYYY HH12:MI:SS AM')
      9                  end_tm
     10           from   dual
     11           union all
     12           select '1-GU-798',
     13                  'Thursday',
     14                  to_date('1/1/1980 7:00:00 AM', 'DD/MM/YYYY HH12:MI:SS AM'),
     15                  to_date('1/1/1980 4:00:00 PM', 'DD/MM/YYYY HH12:MI:SS AM')
     16           from   dual)
     17  select listagg(tm, ' ') within group(order by con_addr_id) val,
     18         min(con_addr_id)                                    con_addr_id
     19  from   (select con_addr_id,
     20                 '&'
     21                 ||substr(start_day, 1, 2)
     22                 ||'='
     23                 ||( ( start_tm - trunc(start_tm) ) * 24 * 60 )
     24                 ||','
     25                 ||( ( end_tm - trunc(end_tm) ) * 24 * 60 ) tm
     26          from   sample_data)
     27* group  by con_addr_id
    SQL> /
    
    VAL                            CON_ADDR
    ------------------------------ --------
    &Th=420,960 &Tu=480,1020       1-GU-798
    
  • Mesh together text of 3 other boxes (easy)

    This one should be easy.  I have 4 textfields:

    first name

    middle_initial

    last_name

    full_name

    All I want to do is add first_name, middle_initial, last_name->-> full_name

    P.S. I'm looking to search before posting, but I had bad wording for get what I was looking for.

    Thank you.

    These are all great scripts, but you can get the OP wanted to do with a much simpler code:

    combinedName var = getField("first_name").value + "" + getField("middle_initial").value + "" + getField("last_name").value; concatenate fields

    combinedName = combinedName.replace(/^\s*/, "") .replace (/ \s*$ /, "") .replace(/\s + / g, ""); "" remove all unwanted spaces

    Event.Value = combinedName; Apply the value combined with this field

  • When I test my recordset I get the data, but when I try to use it I get syntax error

    Hello

    My recordset looks like this and it works when I test it in the "links/Recordset' but when I locked it and I try to click on the + I get an error message. MySQL Error #: 1064

    You have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near "on line 2

    SELECT AuthorID,AuthFname, AuthInitial, AuthLName, @name := (SELECT concat_WS(', ',AuthFname, AuthInitial, AuthLName)
    FROM BookAuthor B
    WHERE A.AuthorID = B.AuthorID )  FROM BookAuthor A
    ORDER BY AuthLName, AuthFname, AuthInitial 
    

    What I'm trying to do is to use the AuthorID as value and the name concatenated for label in a list/menu and choose several authors if necessary when I sign up a book.

    Maybe there's an easier way to do this?

    I tried concatenate fields in the list/menu Dynamics (label), but I could not.

    Any suggestions?

    Best regards

    Anna

    Sorry, your post is very confusing and you have yet to explain why you use a derived table query.

    It seems that you need a simple select statement.

    Select AuthorID, AuthFname, AuthInitial, AuthLName, CONCAT_WS (",", AuthFname, AuthInitial, AuthLName) as an author

    Of BookAuthor

    Note that I do not use MySQL and so not really familiar with its CONCAT_WS function but you get the idea. Am I missing something here?

  • Need to insert the Date and time with AM or PM

    StartDate form has ' 25/07/2006' and Starttime "13:07.
    I need to add this field in the database to display the Date and time with the AM or PM. But the result I get is false.
    <! - concatenate fields - >
    "< cfset Startdate = #Startdate # &" "& #starttime # >.

    < cfset startdate = #DateFormat (CreateODBCDateTime (Startdate), ' mm/dd/yyyy hh: mm: tt ') # >
    Here is my production. This is not the AM or PM conversion part of the chain.

    25/07/2006 01:07 am

    My database is SQL 2000

    You use any of dateformat. The createodbcdatetime sends the correct your DB value if you do it right.

  • Contact field to concatenate when loading? Solutions?

    I need a certain area to concatenate when loading (added value); However, the logic of download is limited to "if white update" or "update otherwise blank", do not leave a lot of logic here:

    Displaying image.png

    If I could write the value in another field, say a temporary, I can't concatenate using the updated rules because the logic it is limited, as well. The only nearby option is "add value." However, that is set to a static value (hardcoded in the update rule), not the value of a field. The other options are "crush of...» » ; that did not help either. I need to manipulate both values to make one with a delimiter.

    Inline image 1

    What are my options here, from rules of game/Dedup or manipulation of strings using cloud connectors? I'm trying to pull this using Eloqua and not a solution custom outside of eloqua.

    If someone has been down this road before?

    If the download of two fields, has a specially designed for this called cloud connector 'string concatenate' rather than 'chain Manipulator. " To the latter I have described above, which works like a charm.

    It would be nice to have some logic to download more than that, even if (as mentioned in my first sentence in the original post)

  • Need to concatenate the put date in the form field and the numeric field

    Hello

    I have a date field and a 4-digit numeric field in my form. I want to concatenate these fields in a new field in the following format: "YYYYMMDD [4-digit numeric field]."

    For example

    Date: June 4, 2015

    Number: 1234

    Concatenated field: 201506041234

    When I try to concatenate the value of date, I get the string value is entered instead of the actual date (e.g. "4 June").

    Thank you.

    OK, the script might like:

    Get the values of field as strings

    var sDate = getField("date1").valueAsString;

    Var Nums = getField("number1").valueAsString;

    Convert string to date in a date object

    Kai var = util.scand ("mm/dd/yyyy", sDate);

    Concatenate number and the date strings

    var sDateNum = util.printd ("YYYYMMDD", letter) + nes;

  • try to concatenate address below fields using javascript

    try to concatenate address below fields using javascript

    this.rawValue = xfa.resolveNode ("#subform [1]..") RawValue CAOName") +"\n"+ xfa.resolveNode (" #subform [1]. ") Addr1") .rawValue | « \n »

      if((xfa.resolveNode("#subform[1].Addr2").rawValue)!= null)
      {
      xfa.resolveNode("#subform[1].Addr2").rawValue}
      else
      {xfa.resolveNode("#subform[1].City").rawValue||xfa.resolveNode("#subform[1].State").rawValue||xfa.resolveNode("#subform[1].Replyzip").rawValue

    but only the name and the addr1 print, can someone help me fix my script... Thank you

    DE1209

    Try something like this:

    this.rawValue = xfa.resolveNode("#subform[1].CAOName").rawValue + "\n" + xfa.resolveNode("#subform[1].Addr1").rawValue + "\n";
    if ((xfa.resolveNode("#subform[1].Addr2").rawValue) != null) {
        this.rawValue = this.rawValue + xfa.resolveNode("#subform[1].Addr2").rawValue;
    } else {
        this.rawValue = this.rawValue + xfa.resolveNode("#subform[1].City").rawValue + xfa.resolveNode("#subform[1].State").rawValue + xfa.resolveNode("#subform[1].Replyzip").rawValue
    }
    
  • concatenate the fields of the record type

    Hello

    Is it possible to concatenate the fields of the record type?, example
    declare 
     TYPE customer_sales_rectype IS RECORD
          (campo1 char(3),
          campo2  char(3),
          campo3  char(3));
    
             
      TYPE ZZZ IS RECORD (kkk customer_sales_rectype);
          x customer_sales_rectype;
         
    begin
      x.campo1:='000';
      x.campo2:='aaa';
      x.campo3:='BBB';
    end;
    I have a table
    ID_REPORT NUMBER                                   
    ID_LINE     NUMBER                                  
    DT_FILE  DATE           Y                        
    DS_LINE     VARCHAR2(2048) Y       
    My charly had more than 50 columns and unavoidable to concatenate the columns, example:
    select column001 ,
           ';' PV1,
           COL2,
           COL3
           COL4,
         ';' PV2,....ETC
    FROM MY TABLES
    I think that movement query result in a variable of type record that I would can insert in the table in the column is DS_LINE some transformatcion.

    Is it possible without using COL1 | PV1. COL2. COL3 | COL4 | PV2... etc.


    Thanks in advance
    using 9.2.02

    It's pretty easy to write a function for this. Here's a 'coffee time ': implementation

    create or replace function multi_concat
        (p_args sys.dbms_debug_vc2coll)
        return clob
    as
        rv clob;
    begin
        dbms_lob.createtemporary(rv, TRUE);
        for i in p_args.first .. p_args.last
        loop
            dbms_lob.writeappend(rv, length(p_args(i)), p_args(i));
        end loop;
        return rv;
    end multi_concat;
    /
    

    And the proof of coffee is in the dip of the ring:

    SQL> select multi_concat ( sys.dbms_debug_vc2coll ( ('Red Fish', 'Blue Fish', 1, 'Fish',2,'Fish'))
      2* from dual
    
    MULTI_CONCAT(SYS.DBMS_DEBUG_VC2COLL('REDFISH','BLUEFISH',1,'FISH',2,'FISH'))
    --------------------------------------------------------------------------------
    Red FishBlue Fish1Fish2Fish
    
    SQL> 
    

    I add a member TO_STRING function to your type and use something like the above, implement.

    You can also use the data dictionary to generate a string that connects the attributes of your type with the concatenation operator.

    Cheers, APC

  • How to concatenate several numbers in a single number fields?

    I have a form of Government that I need to add a few calculations to. The problem is that the initial numbers must be included in the three fields separate one to thousands, millions and billions of dollars. The Government entity does not allow me to change the entry in the form.

    So, I'll have a field for so many billions, for so many thousands and millions. I have to be able to take these three fields and create a new field with a unique number in it. For example: field = 22 billion, field B = 345 million and field C = 987 thousand. I want to concatenate these three fields for the new field will read: $22,345,987,000.

    Concatenate Fields.jpg

    Then, I need to be able to hide this field, but still be able to use for calculations. I will be adding and subtracting the numbers in a column for totals and totals. I can do it in Acrobat or do I need to do in Live Cycle Designer or to another program?

    Any help will be greatly appreciated.

    You just need a calculation script custom which multiply each number by its multiplier and add them up. Something like this:

    var g = this.getField("Billions").value;

    millions var = this.getField("Millions").value;

    thousands of var = this.getField("Thousands").value;

    Event.Value = (g * 1000000000) + (millions * 1000000) + (thousands * 1000);

  • 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

  • How do you concatenate constants and fields in a model

    I have problems to make my phone numbers to be formatted correctly in a BEEP pattern that must generate an Excel output.  I use the following formula in it:

    <? xdoxslt:ifelse(contains((WorkPhone)[1],'+'),(WorkPhoneDisplay)[1],psfn:phoneFormat((WorkPhone)[1]))? >

    The XML looks like this:

    < As WorkPhone > + 46051084500 < / as WorkPhone > Type = DTYPE_PHONE

    < WorkPhoneDisplay > + 46051084500 < / WorkPhoneDisplay Type = DTYPE_TEXT

    If the phone number is up to US, it does not work as expected, but when it is International, it is down the + sign and convert the phone number and displaying as 4.60511E + 11.  I'm trying to concatenate a + in front of the number in the pattern so that it is displayed as + 46051084500.  Can someone give me the syntax I should use for this?  I tried different ways, but nothing seems to work.

    Thank you!!!

    ....

    He is dropping the + sign and convert the phone number and displaying as 4.60511E + 11

    Try

    =""

    or

    nonbreaking space

    where 'non-breaking space' is the non-breaking space in ms word

  • How to carve, and concatenate the two text fields in a form

    Hi people,

    Newbie here... have two fields in a form: FirstName and LastName.    Want to have these appear later as: name, first name.

    For example: 'Rick' "Stockstill" should later manifest as: 'Stockstill, Rick' with a comma separating the names and trailing blanks removed.

    It is a piece of cake in Excel, but have not figured out how to do the same with Acrobat.    My first try at a script looks like this:

    (Recipient.rawValue = trim (LastName.rawValue) +","+ FirstName.rawValue);

    The field 'Recipient' is a standard text field which I am filling using the property to 'calculate '.  The good news is that I get no error message, but the bad news is that the field recipient does not get filled.

    Any help is greatly appreciated.

    At the latest,
    Rick Stockstill
    North East Independent School District
    San Antonio, TX
    210-407-0317.
    [email protected]

    OK, in this case you can use this code as the custom recipient field calculation script:

    event.value = trim(this.getField("LastName").valueAsString) + ", " + trim(this.getField("FirstName").valueAsString);
    
    function trim(s) {
        return s.replace(/^\s+/,"").replace(/\s+$/,"");
    }
    

Maybe you are looking for

  • OS installs not after restoring to factory settings

    I've restored my HP DV5 laptop to factory settings. Once the restoration is complete, the computer restarts, but whenever it starts up and begins to install windows, a window appears indicating that an error has been encountered during installation.

  • OJ6500A more: 6500 a do not print

    6500 a plus will not pick up paper and do not print guard saying no. paper in the tray

  • Card slot Radio does not play

    I bought a rocket as a Valentine's day gift for my wife and got a slot Radio card at the same time. I've upgraded to the latest firmware and the "rocket" shows the Radio slot on the menu screen, when I put in the card and select location Radio it kee

  • microphone is very noizy

    I have Windows vista home When I work with, online, my client is not here my voice, sound strongly. I am also checking my microphone, can't my voice, I think that my microphone is function, but heavy noisy sound How to solve the problem?

  • Tech deleted drive d factory, and now he is said to be complete and is remembered up to d drive

    My d drive is send me notifications for low disk space since a tech based on what I've been well HP, practically entered my pc give me windows 7 to fix a corrupted profile. He has saved and seemed to save my old stuff under the drive c as windows.old