sql - How to get 2 aggregate functions in one FetchXML script? -
sql - How to get 2 aggregate functions in one FetchXML script? -
let's have dataset:
+--------+-------+----------+ | animal | cost | foodcost | +--------+-------+----------+ | 1 | 23 | 22 | | 1 | 32 | 33 | | 1 | 7 | 69 | | 2 | 45 | 55 | | 2 | 432 | 82 | | 2 | 33 | 34 | | 3 | 67 | 44 | | 5 | 671 | 62 | | 8 | 234 | 43 | +--------+-------+----------+
the result looking in tablix is:
+--------+-------+----------+ | animal | cost | foodcost | +--------+-------+----------+ | 1 | 62 | 124 | | 2 | 510 | 171 | | 3 | 67 | 44 | | 5 | 671 | 62 | | 8 | 234 | 43 | +--------+-------+----------+
i understand how 1 aggregate, how 2 aggregates, namely, summing cost , foodcost each animal?
sql:
select animal, sum(price) sum_price, sum(foodcost) sum_foodcost dbo.aggegatetest grouping animal
generated fetchxml: http://sql2fetchxml.com/
<fetch aggregate="true" mapping="logical"> <entity name="aggegatetest"> <attribute name="animal" alias="aggegatetest1.animal" /> <attribute name="price" alias="sum_price" aggregate="sum" /> <attribute name="foodcost" alias="sum_foodcost" aggregate="sum" /> <attribute name="animal" alias="animal" groupby="true" /> </entity> </fetch>
sql sql-server visual-studio reporting-services fetchxml
Comments
Post a Comment