【问题标题】:Sum of sub query in cds viewcds 视图中子查询的总和
【发布时间】:2018-05-25 03:43:24
【问题描述】:

我无法汇总 cds 视图中的数据。在 Hana 计算视图的早期,下面的查询根据我的意愿给我结果

从 T1 中选择 t1.ID、t1.Name、t1.qty、t2.amount Inner join (select ID, Name, Sum (amount) from t2 group by ID, Name) as T2

但是cd中的金额总和不正确..请帮助

【问题讨论】:

  • 请提供示例 CDS 视图

标签: abap hana-studio cds


【解决方案1】:

您可以在 SELECT 语句中使用聚合表达式。这样您就可以从结果集的多行中调用聚合函数:

@AbapCatalog.sqlViewName: 'SALES_ORDER_VW'
define view sales_order as
select from snwd_so
{ key buyer_guid,
   @Semantics.currencyCode
    currency_code,
   @Semantics.amount.currencyCode: 'currency_code'
    sum(gross_amount) as sum_gross_amount }
group by buyer_guid, currency_code

所以在你看来,你可以这样做:

sum(name_of_field) as sum_of_field

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-05
    • 2011-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多