IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.


#TechXchangePresenter
 View Only
Expand all | Collapse all

avg() and sum() not working

  • 1.  avg() and sum() not working

    Posted Tue November 18, 2003 11:23 AM

    I cannot get avg() or sum() to work, although min() and max() work fine.

    Take a look at the following code:

    {let $a := avg($subquery//count) return

    {$a}

    }

    This produces a ‘Runtime type exception’, as does sum(). But if I use min() or max(), it works fine.

    Can someone tell me what I am doing wrong?


    #Tamino
    #webMethods
    #API-Management


  • 2.  RE: avg() and sum() not working

    Posted Mon December 01, 2003 10:44 AM

    Hi Simon,

    min() and max() differ from avg() and sum() in that they just
    require the type of its argument list entries to be sortable,
    whereas for avg()and sum() the arguments must also allow for a
    certain kind of arithmetic. Since your example works with min()
    and max() and not for avg() and sum() the entries of the argument
    list are obviously of a sortable type but not able to be added
    up. Most likely they are strings. Try change your Tamino Schema
    definition to define the count field as, say, integer or use the
    number() function as follows:

    avg(for $x in $subquery//count
    return number($x))

    regards,
    Juliane.


    #Tamino
    #API-Management
    #webMethods