Aggregation doesn't seem to match data in the VersionOne RESTful API

南笙酒味 提交于 2019-12-24 11:14:04

问题


Given this query (spacing added for readability):

rest-1.v1\Data\Story?
    sel=
        Children.ID,
        Children.Actuals.Value,
        Children:Task.@Count,
        Children.Actuals.Value.@Sum.Value
    &where=Number='B-02833'

I received the following in response:

<Assets total="1" pageSize="2147483647" pageStart="0">
    <Asset href="/rest-1.v1/Data/Story/13195" id="Story:13195">
        <Relation name="Children.ID">
            <Asset href="/rest-1.v1/Data/Task/34505" idref="Task:34505"/>
            <Asset href="/rest-1.v1/Data/Task/34506" idref="Task:34506"/>
            <Asset href="/rest-1.v1/Data/Task/34507" idref="Task:34507"/>
        </Relation>
        <Attribute name="Children.Actuals.Value.@Sum">97.2</Attribute>
        <Attribute name="Children.Actuals.Value">
            <Value>1</Value>
            <Value>2</Value>
        </Attribute>
        <Attribute name="Children:Task.@Count">6</Attribute>
    </Asset>
</Assets>

Can someone explain why the values returned total to 3, but the .@Sum shows 97.2?


回答1:


The most likely cause is that aggregate functions like @Sum and @Count don't automatically ignore deleted/dead assets.

You probably want to say something like:

rest-1.v1\Data\Story?
    sel=
        Children.ID,
        Children.Actuals.Value,
        Children:Task[AssetState!=Dead].@Count,
        Children[AssetState!=Dead].Actuals.Value.@Sum.Value
    &where=Number='B-02833'


来源:https://stackoverflow.com/questions/13614360/aggregation-doesnt-seem-to-match-data-in-the-versionone-restful-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!