Operand data type char is invalid for sum operator

can someone help me re-writing the following so I wont keep getting thie baopv ementioned error: here is the statement:
RIGHT('0000000000'+REPLACE(CAST(SUM(PAID_AMT) AS VARCHAR),'.',''),14) AS TOT_NET_PAID
+
RIGHT('0000000000'+REPLACE(CAST(SUM(PAID_AMT)
AS
VARCHAR),'.',''),14)
AS TOT_NET_PAID
It keeps retuning he following error messages:
Operand data type char is invalid for sum operator

As Jingyang said, you cannot sum a non numeric field. Cast it to a numeric first (INT maybe?)
+ RIGHT('0000000000'+REPLACE(CAST(SUM(CAST(PAID_AMT AS INT)) AS VARCHAR),'.',''),14) AS TOT_NET_PAID
Don't forget to mark helpful posts, and answers. It helps others to find relevant posts to the same question.

Similar Messages

  • Argument data type varchar is invalid for argument 1 of formatmessage function

    So, I have a need to parameterize my templates so I can dynamically compile and execute them as needed. I have read on some blogs that it is possible to use FORMATMESSAGE  for user string formatting but I can't seem to get that working on my end and
    would appreciate help getting this running. 
    I continually run into the following error message
    Msg 8116, Level 16, State 1, Line 9
    Argument data type varchar is invalid for argument 1 of formatmessage function.
    when I try to execute either of  the queries below
    1) 
     SELECT FORMATMESSAGE ( CAST('%s' AS VARCHAR(10)), 'name' );
    2) 
    -- printf formatting  %[[flag][width][.precision]]typeDECLARE @Format CHAR(1)         = ''   -- '',+,-,0,#,' '      , @Width INT              = 6    -- display field size      , @Precision INT          = 3    -- characters to display      , @Type CHAR(1)           = 'X'  -- s, d, i, u, o, x, X      , @Binary VARBINARY(128)  = 0x1239       , @Int INT                = 11                      , @String NVARCHAR(128)   = N'test';  DECLARE @$QL NVARCHAR(256) = ( SELECT FORMATMESSAGE( N'SELECT FORMATMESSAGE(''%%s -->%%%s*.*%s<--'', @$QL, %i, %i, %s)'                      , s.Flag                       , f.Type                      , @Width                      , @Precision                       , CASE WHEN @Type = 's'                              THEN FORMATMESSAGE('''%s''', @String)                             WHEN @Type = 'd'                             THEN FORMATMESSAGE('%d', @Int)                             WHEN @Type = 'i'                             THEN FORMATMESSAGE('%i', @Int)                             WHEN @Type = 'u'                             THEN FORMATMESSAGE('%u', @Int)                             WHEN @Type = 'o'                             THEN FORMATMESSAGE('%o', @Int)                             WHEN @Type = 'x'                             THEN FORMATMESSAGE('%x', @Binary)                             WHEN @Type = 'X'                             THEN FORMATMESSAGE('%X', @Binary)                             END )   FROM (SELECT           ('') AS Flag         UNION ALL SELECT ('+')          UNION ALL SELECT ('-')          UNION ALL SELECT ('0')          UNION ALL SELECT ('#')          UNION ALL SELECT (' ') ) AS s         CROSS JOIN (SELECT           ('s') AS Type               UNION ALL SELECT ('d')               UNION ALL SELECT ('i')               UNION ALL SELECT ('u')               UNION ALL SELECT ('o')               UNION ALL SELECT (LOWER('x'))               UNION ALL SELECT (UPPER('X')) ) as f   WHERE CHARINDEX(@Format,s.Flag) > 0   AND ASCII(f.Type) = ASCII(@Type) );EXEC sp_executesql @$QL, N'@$QL NVARCHAR(256)', @$QL;
    [email protected]

    Hi Databyter,
    Based on my testing, the first query runs fine in a SQL Server 2012 while I got the same error in your post when trying to run it in a SQL Server 2008R2.
    After going through the BOL of the FORMATMESSAGE for both versions, something came into my sight.  The note below was removed in the 2012 BOL.
    FORMATMESSAGE works only with messages created using
    sp_addmessage.
    BOL:FORMATMESSAGE(2008)
    BOL:FORMATMESSAGE(2012)
    The messages created using sp_addmessage can be viewed by using the sys.messages. Thus in SQL Server 2008, you have to follow the example to use the function or you get the error in your post.
    SELECT * FROM sys.messages WHERE message_id = 20009 AND language_id = 1033;
    DECLARE @var1 VARCHAR(200);
    SELECT @var1 = FORMATMESSAGE(20009, 'First Variable', 'Second Variable');
    SELECT @var1;
    For some reason the limitation is removed in SQL Server 2012, that's why your first query runs fine.
    If you have any feedback on our support, you can click
    here.
    Eric Zhang
    TechNet Community Support

  • Data types are not appropriate for Relationnal operation, strange error ?

    Hi,
    we try to connect send (thanks jdbc:odbc) a query contening a WHERE statment with date (a BETWEEN). Unfornately we received an error message (see title). We know that the field is in DateTime format (like mm/dd/yyyy hh:mm:ss aa).
    Is anybody able to find an issue to perform this relationnal operation ?
    Thanks

    Oooops I forgot,
    This is my Query
    String PatQuery="SELECT HelpDeskCases.\"Case-ID+\", HelpDeskCases.\"Assignee-Login-Name\", HelpDeskCases.\"Create-Time\", HelpDeskCases.\"Resolved-Time\" FROM HelpDeskCases WHERE HelpDeskCases.\"Create-Time\" >=" + ddeb + " AND HelpDeskCases.\"Resolved-Time\" <=" + dfin ;
    Regards

  • Data type-Char?

    Hi experts,
    A simple query. Do the data type CHAR accepts the values like 8923, 452A, etc? while creating an infoobject.?
    Thanks in advance.
    Regards
    Dubbu

    Yes it accepts .
    for data consistency you have to maintain alfa conversion.
    Regards,
    Ramnaresh.

  • Data Type Is Not Vailid for Input

    Hello,
    I'm new in (ABAP) WebDynpro and I have a problem with displaying data - particularly with HROBJECTs from our e-Recruiting system.
    In my WebDynpro-Component i read some data of candidates into my context. One table (with candidate-infos) which i save in my context includes a field which is datatype of HROBJECT. After I've read this infos into my itab, I bind this table to my context. All this works fine! But as soon as I bind this context to a table-ui-element in my layout, i get a error message "Data Type Is Not Valid for Input", when i start the application.
    If I delete the binding with the attribute which is a HROBJECT, it works.
    Runtime Errors         UNCAUGHT_EXCEPTION
    Exception              CX_WDR_CONVERSION_EXCEPTION
    Information on where terminated
        Termination occurred in the ABAP program "CL_WDR_CONVERSION_UTILS=======CP" -
         in "IF_WD_CONVERSION_UTILS~TO_STRING".
        The main program was "SAPMHTTP ".
        In the source code you have the termination point in line 138
        of the (Include) program "CL_WDR_CONVERSION_UTILS=======CM00G".
        The termination is caused because exception "CX_WDR_CONVERSION_EXCEPTION"
         occurred in
        procedure "IF_WD_CONVERSION_UTILS~TO_STRING" "(METHOD)", but it was neither
         handled locally nor declared
        in the RAISING clause of its signature.
        The procedure is in program "CL_WDR_CONVERSION_UTILS=======CP "; its source
         code begins in line
        1 of the (Include program "CL_WDR_CONVERSION_UTILS=======CM00G ".
    136     WHEN cl_abap_typedescr=>typekind_struct1    "'u'     " structure
    137     OR   cl_abap_typedescr=>typekind_struct2.   "'v'.    " structure
    >>>>       RAISE EXCEPTION TYPE cx_wdr_conversion_exception exporting textid = cx_wdr_conversion_
    139 *      raise exception type cx_wdr_conv_unsupported exporting type_name = l_type.
    Please Help.
    Thanks

    now i've tried it with a independent candidate node (without) supply funciton. =>
    The same error: "Data Type Is Not Vailid for Input"
    Here's the code of my supply-function:
    (probably not the best coding - but it works until i want to display a hro.)
    METHOD get_cand_info .
      DATA: lr_cdcy                    TYPE REF TO cl_hrrcf_candidacy_bl,
            lr_cand                    TYPE REF TO cl_hrrcf_candidate_bupa_bl,
            stru_requisitions          TYPE if_componentcontroller=>element_requisitions ,
            lt_h_cdcy_list             TYPE rcf_t_list_candidacies_x,
            ls_h_cdcy_list             TYPE rcf_s_list_candidacies_x,
            lt_cdcy_list               TYPE if_componentcontroller=>elements_candidate,
            ls_cdcy_list               TYPE if_componentcontroller=>element_candidate,
            lt_addr                    TYPE rcf_t_addressdata_bp,
            ls_addr                    TYPE rcf_s_addressdata_bp,
            lt_email                   TYPE rcf_t_emaildata_bp,
            ls_email                   TYPE rcf_s_emaildata_bp.
    * get all declared attributes
      parent_element->get_static_attributes(
        IMPORTING
          static_attributes = stru_requisitions ).
      CALL METHOD cl_hrrcf_candidacy_bl=>get_instance
        RECEIVING
          return = lr_cdcy.
      CALL METHOD cl_hrrcf_candidate_bupa_bl=>get_instance
        RECEIVING
          return = lr_cand.
    * Hole Kandidatur-Informationen der Kandidaten
      TRY.
          lr_cdcy->get_candidacy_list_x(
            EXPORTING
              ps_req_hrobject  = stru_requisitions-hrobject
    *    ps_cand_hrobject =
    *    ps_appl_hrobject =
    *    p_exclude_draft  = 'x'
            IMPORTING
              pt_candidacies_x = lt_h_cdcy_list
        CATCH cx_hrrcf .
      ENDTRY.
    * Ergänzen der Informationen mit BusinessPartner-Infos
      LOOP AT lt_h_cdcy_list INTO ls_h_cdcy_list.
        TRY.
            lr_cand->get_contact_data(
              EXPORTING
                ps_cand_hrobject = ls_h_cdcy_list-cand_hrobject
              IMPORTING
                pt_addressdata   = lt_addr
    *    pt_telefondata   =
    *    pt_faxdata       =
                pt_emaildata     = lt_email
          CATCH cx_hrrcf .
        ENDTRY.
        READ TABLE lt_addr INDEX 1 INTO ls_addr.
        READ TABLE lt_email INDEX 1 INTO ls_email.
        MOVE-CORRESPONDING ls_h_cdcy_list TO ls_cdcy_list.
        ls_cdcy_list-postcode1 = ls_addr-postl_cod1.
        ls_cdcy_list-city1 = ls_addr-city.
        ls_cdcy_list-email = ls_email-e_mail.
        APPEND ls_cdcy_list TO lt_cdcy_list.
      ENDLOOP.
      CALL METHOD node->bind_table
        EXPORTING
          new_items = lt_cdcy_list.
    ENDMETHOD.

  • Date type-specific Customizing missing for date type ACTActPln

    Hi all.
    I'm using a Web Service obtained by copying the CRM 7.0 built-in WS APPTACTCRTRC.
    I'm using it to create Appointments using an Adobe Interactive Form.
    It goes everything fine (a Date is created in the system, with all the input data properly set) excepted the dates...
    The WS uses two TIMESTAMPS, TIMESTAMP_FROM for StartDateTime and TIMESTAMP_TO for EndDateTime, whereas the GUI transaction to create Dates accepts dates and times in separated fields.
    Going in Debug I can see that the execution ends with the following error, referred to the involved entity (CRM_APPOINTMENT):
    Date type-specific Customizing missing for date type ACTActPln
    CRM_APPOINTMENT uses date profile 0000000001 with three possible date types: ORDERACTUAL, ORDERPLANNED and ORDERPROPOSED and I cannot find anywhere date type ACTActPln (just to add it in customizing).
    Is anyone able to enlight me?
    Thank you in advance!
    Alessandro
    PS I've years of experience in Java programming but I'm quite new to the SAP world. Maybe the problem is not a problem at all, but it seems to me as such. Even if it has a trivial solution, please let me know. Thx!

    Hi,
    Well I was about to write that you should enter date in decimal format. but you already did that as mentioned in How to set a date in a Form where the bound date format is a decimal?
    In response to following from above thread (copied for others to understand my response)
    Hi all.
    I'm successfully using the LiveCycle Designer and I've managed to remotely create Appointments using a CRM Web Service (a mere copy of APPTACTCRTRC).
    The only problem I'm encountering is that I'm not able to set the dates/times (start and end of the appointment).
    Dragging each of the two fields from the WSDL based Data Connection I obtain a Decimal Field limited to 15 digits.
    How can I write a date and time in such a field?
    I've tried with a retroverse date as YYYYMMDDHHmmss (for example, 20100301124500) but it does not work
    (the appointment is indeed created, but with the start date and time fields filled with
    the current date/time and the end date and time fields filled with the current date and time plus 10 minutes).
    The retroverse date above is only 14 digit long, so, maybe, this is the problem.
    But, given the field definition, I'm not able to fill a blank space between the date and the time.
    I'm not able to put a dot either.
    What should I do?
    Any suggestions?
    Thank you in advance.
    Alessandro
    15 digit in UTC time format here is fraction of second so you should enter 201003011245000 (add one more zero).
    14th Oct 2010 16:00 should be written as 201010141600000, so just try it and and see if it works, I guess if you do not supply end time then by default it will be starttime + 10 min but this is just guess.
    Regards,
    Gourav

  • XML operation resulted an XML data type exceeding 2GB in size. Operation aborted.

    I have table with one million rows, when i am using xml path ('Root'), it giving me an error 
    "XML operation resulted an XML data type exceeding 2GB in size. Operation aborted."
    This is a limitation of sqlserver. I have to xml path because i have to create nodes and attributes. In more complex case i will be joining multiple tables to get id and other attributes so combining multiple xmls in not an option here.
    any workaround....thanks in advance

    Here an example of your query that retrieve record in batch of 2 records. In real code, you should save the last id retrieved and call the query in a loop.
    DECLARE @BATCHSIZE AS integer
    SET @BATCHSIZE = 2
    DECLARE @LASTID As Integer
    SET @LASTID = 0
    select top(@BATCHSIZE) id as "@id"
    ,name as "@name"
    select id as "@id"
    ,name as "@name"
    select *
    from @products p
    where p.customer_id = cs.id
    group by id,customer_id,name
    for xml path ('product'),Root('products'),type
    from @customer cs
    where cs.client_id = c.id
    group by id,client_id,name
    for xml path ('customer'),Root('customers'),type
    from @client c
    where c.id > @LASTID
    order by c.id
    for xml path ('clients'),Root ('Main')

  • The Employer Type selected is invalid for iRecruitment

    Hi.
    I get "The Employer Type selected is invalid. Please enter a valid Employer Type" error message when try to to enter previous employer for externel candidate. What's wrong?
    Thanks.

    I fix it. Data grid where you enter previous employement doesn't render employee type column. I have added it. Now it works.
    Thank you for response.

  • Dataelement of data type char but accepts only integers

    Hi Experts,
    I have a scenario where quantity field in output is editable and the user wants the quantity field printed without thousand separator. If i take a char field and display the field is editable then user may mistakenly type a,bcd...z/ special characters which it should not capture. Is there any char data type data element which accepts only integers. Because after that i need to save that value in z database table quantity field.
    Please share your suggestions.

    I have a scenario where quantity field in output is editable and the user wants the quantity field printed without thousand separator.
    I'm a bit lost with your statement, as you consider changing the data type it sounds like you have control over the program and thus most likely also over the forms (assuming that printing means sending some output to a printer). In that case I'd first consider keeping the quantity field as is and change the output logic (e.g. print program or form) so that the group (thousands) separator doesn't appear for that quantity field (and refrain from changing the field definition). (Similarly if it's just concerning the output of a field on the screen then an appropriate output mask/template for that screen field should be the right way to go.)

  • Difference between Data Type Char & VarChar

    Hi Experts,
    I a design document that I have, some of the Data Types are mentioned as CHAR(e.g.CHAR(4)), and a few others as VARCHAR(e.g.VARCHAR(20)), can you let me know what is the difference between the two.And how is such an object to be developed in BW seeing that we don't have a DataType called Varchar in BW?
    Thanks
    Aravind

    Hi
    The char is a fixed-length character data type, the varchar is a variable-length character data type.
    Because char is a fixed-length data type, the storage size of the char value is equal to the maximum size for this column. Because varchar is a variable-length data type, the storage size of the varchar value is the actual length of the data entered, not the maximum size for this column.
    You can use char when the data entries in a column are expected to be the same size.
    You can use varchar when the data entries in a column are expected to vary considerably in size.
    but that is no need in SAP BW, any how you are going to assign the length of the variable while creating...
    Thanks
    M Kalpana

  • Asset History Sheet giving Report date 31.03.2008 invalid for this report

    S_ALR_87011990 :Asset History Sheet.
    Report date 31.03.2008 is invalid for this report
    In the above report, if we give the Report Data, as any date other than the end month of the fiscal year, it gives the error " Report date 31.03.2008 is invalid for this report"  We require this report for tax purpose upto 31st Mar08
    What needs to be done ?
    Thanks
    amit

    Hi Amit,
    In AM you can only report on the dates you have set-up in period control. In the most cases this is the last day of the Month.  When you have 13 periods from 4 weeks you can't report on the calendar month end.
    Paul

  • Selection Sorting of Data type (Char)

    public class CharSortTest {
        public static void main(String[] args) {
            char[] letters = {'j', 'a', 'z', 'y', 'x'};
            char min = 0;
            char swap = 0;
            for (int x = 0; x <= letters.length - 1; x++) {
                min = letters[x];
                for (int i = x + 1; i <= letters.length - 1; i++) {
                    if (letters[i] < min) {
                        min = letters;
    if (letters[x] != min) {
    swap = letters[x];
    letters[x] = min;
    min = swap;
    for (int p = 0; p <= letters.length - 1; p++) {
    System.out.println(letters[p]);
    }output:a
    a
    x
    x
    xi followed the logic of selection sorting.. i even checked the integer values of each character in my array
    but why is my program not sorting                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    vajj wrote:
    public class CharSortTest {
    i followed the logic of selection sorting..Obviously you didn't.
    Put in print statements at each step so you can see exactly what's happening--varaibles' values, code paths being followed, etc.

  • Delclaration of data type Char

    Hi Friends,
    My Requirement is as follows.
    I am having the amount filed.I have declared the Var as data var1 type P decimals 2.But Now In the output i am getting the the variable value as ****44.000.So Start(* is nothing but spaces.So I am getting 5spaces and then priting the value 44.000.So how to avoid that spaces..DO i need to declare some thign else for this..
    Regards,
    Sai

    Hi, plz check the code.
    Report zabc.
    parameters: p1 type p decimals 2.
    data: d1 type char10.
    d1 = p1.
    condense d1.
    write:/ ' the amount is ', d1.
    Regards,
    Sakthi sri.

  • Binary Data Type in finder methods for CMP beans

    How to write an equivalent ejb-ql query in ejb-jar.xml for a finder method accepting
    a byte array as a parameter. The finder method is for a cmp-field mapped to a
    database field with binary data type

    Using CMP 2.x, your custom finder and select methods are implemented by the container based on the EJB QL query you provide in the ejb-jar.xml. In CMP 1.1, there was no portable way to express the semantics of the query, so most vendors had a vendor-specific syntax for describing the query.
    See chapter 27 of the J2EE 1.4 Tutorial for some examples of using EJB QL :
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.html
    --ken
    Kenneth Saks
    J2EE SDK Team
    SUN Microsystems

  • What type of data type would I use for this situation?

    I have a class which connects to Oracle, but each connection may be to a different database. Each database has it's own user name and password.
    I'd like to pass one key value and then the class would get the user name and password and url from that but not sure how to do it.
    Right now, for the function I pass it the url, username, password which then calls a connection function and passes it the same value. This seems messy keep passing values around.
    Is there some kind of enumerations or something ?

    You might consider putting the URLs, usernames and password into a properties file.
    The properties file might contain:
    all.databases=database1,database2,database3
    database1.user=user1
    database1.password=dingbat
    database1.url=jdbc:oracle:thin:dohdah:base1
    database2.user=someone
    database2.password=toad
    database2.url=jdbc:oracle:thin:xyx:dsds
    Then use ResourceBundle.getBundle() to load the properties and you can just do
    Connection con = DriverManger.getConnection(bundle.getString(key + ".url"),bundle,getString(key + ".user"), bundle.getString(key + ".password");

Maybe you are looking for