正确的语法或CASE HANA SQL

2020-09-14 23:09发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)下午大师的 在 SQL计...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


下午大师的

在" SQL计算"视图中针对FAGFLEXT选择时,我正努力获得正确的结果:我正在尝试将一行转置为添加句点的列。 结果

是不一致的,因此第一个组合中有值的期间始终存在,但余额正确,然后其余错误。 我尝试过总和/组没有什么区别

选择" RYEAR",

(" HSL01"时为<> 0,然后为" 01"时

当" HSL02" <> 0 THEN'02'..... ELSE'16'END)为" PERIOD"时,

" RTCUR",

" PRCTR",

(以" HSL01"为例,然后为0,然后是" HSL01"

当" HSL02" <> 0然后是" HSL02" ......

ELSE" HSL16" END)作为"余额"

来自" xxxxx。" FAGLFLEXT"

" RLDNR" ='0L';

3条回答
半个程序猿
2020-09-14 23:13 .采纳回答

Fiona嗨,

是的,这将是不一致的,因为当找到对应的Period的值时,控件从CASE中消失了。 该SQL应该会为您提供所需的结果。

 SELECT * FROM(选择" RYEAR",当" HSL01"时为例<> 0 THEN'01'结束" PERIOD"," RTCUR"," PRCTR"," HSL01"时为例>>然后则" HSL01"结束 作为" SCHEMA"中的" BALANCE"。" FAGLFLEXT" UNION选择" RYEAR",当" HSL02" <> 0时为例,然后以" PERIOD"," RTCUR"," PRCTR"结尾,当" HSL02" <>时为例 0然后,从" SCHEMA"以" BALANCE"结尾" HSL02"。以" HSL03"为例," FAGLFLEXT" UNION选择" RYEAR",然后以" HSL03"结尾的情况下为0。然后从" 03'END" PERIOD,RTCUR,PRCTR 当" HSL03" <> 0然后从" SCHEMA"以" BALANCE"结束时。" FAGLFLEXT"联合选择" RYEAR"," HSL04" <> 0然后以'04'结束" PERIOD"," RTCUR"  ," PRCTR",当" HSL04" <> 0然后以" BALANCE"结束时为" SCHEMA"的情况。" FAGLFLEXT" UNION选择" RYEAR",以" HSL05" <> 0 THEN'05'结束"的情况 PERIOD"," RTCUR"," PRCTR",当" HSL05" <> 0时为大写,然后以"平衡"从" SCHEMA"结尾为" HSL05"。" FAGLFLEXT" UNION选择" RYEAR",当为" HSL06" <>时为大写 然后以" HSL06" <> 0开头的情况下,'06'结尾于" PERIOD"," RTCUR"," PRCTR"时,则以" SCHEMA"中的" BALANCE"作为结束。  AGLFLEXT" UNION选择" RYEAR",以" HSL07"为例,然后以" 0"'07'结束,以" PERIOD"," RTCUR"," PRCTR"为例,以" HSL07" <> 0则以" BALANCE"结尾 从" SCHEMA"开始。" FAGLFLEXT" UNION选择" RYEAR",当" HSL08" <> 0时为例,然后" PERIOD"," RTCUR"," PRCTR",当" HSL08" <> 0时为例,然后" HSL08"  "以" SCHEMA"结尾的" BALANCE"结尾。" FAGLFLEXT" UNION选择" RYEAR",以" HSL09"为例<> 0然后'09'结束" PERIOD"," RTCUR"," PRCTR",以" HSL09"为例 <> 0然后从" SCHEMA"以" BALANCE"作为"余额"结尾。" FAGLFLEXT" UNION选择" RYEAR",以" HSL10"为例<> 0然后从" 10"结束" PERIOD"," RTCUR"," PRCTR"  ,当" HSL10" <> 0然后将" HSL10"结束时作为" SCHEMA"中的" BALANCE"的情况。" FAGLFLEXT"联合选择" RYEAR",当" HSL11" <> 0然后'11'结束" PERIOD","  RTCUR"," PRCTR",当" HSL11" <> 0时为大写,然后以"平衡"作为"平衡"从" SCHEMA"结束。" FAGLFLEXT" UNION选择" RYEAR",当为" HSL12" <> 0则为'12' 当" HSL12" <> 0时,以" PERIOD"," RTCUR"," PRCTR"为例,然后以" SCHEMA"的" BALANCE"结尾" HSL12"。  LEXT" UNION SELECT" RYEAR"," HSL13" <> 0则为例,然后'13'结束。" PERIOD"," RTCUR"," PRCTR"," HSL13" <> 0则为" BALANCE"时的情况 从" SCHEMA"开始。" FAGLFLEXT" UNION选择" RYEAR",当" HSL14" <> 0时为例,然后以"句号"," RTCUR"," PRCTR"结束,当" HSL14" <> 0时为例,然后" HSL14"  "以" SCHEMA"结尾的" BALANCE"结尾。" FAGLFLEXT" UNION选择" RYEAR",以" HSL15"为例<> 0 THEN'15'结束" PERIOD"," RTCUR"," PRCTR",以" HSL15"为例 <> 0然后将" HSL15"作为"平衡"从" SCHEMA"结束。" FAGLFLEXT" UNION选择" RYEAR",以" HSL16"为例<> 0然后将" 16"结束" PERIOD"," RTCUR"," PRCTR"  ,当" HSL16" <> 0然后将" HSL16"以" SCHEMA"。" FAGLFLEXT"结尾的" BALANCE"结束时,情况下,按RYEAR,PERIOD顺序不为空; 

谢谢,
钱德拉。

一周热门 更多>