点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)大家好, 我需要将类似于以下提...
点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)大家好, 我需要将类似于以下提...
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
大家好,
我需要将类似于以下提到的查询从SQL迁移到HANA。 有人可以就这个话题提供建议吗?
声明@Anexo NVARCHAR(1)
声明@PN NVARCHAR(15)
声明@Total NUMERIC(19,6)
创建表#tabela(Anexo NVARCHAR(1),PN NVARCHAR(15),总计NUMERIC(19,6))
DECLARE c1光标用于
从OPCH中选择" A",CardCode和DocTotal
打开c1
从c1下一步获取@ Anexo,@ PN,@ Total
@@ fetch_status <> -1
开始插入#tabela(Anexo,PN,总计)
值(@ Anexo,@ PN,@ Total)
从c1下一步获取@ Anexo,@ PN,@ Total
结束
关闭c1
取消分配c1
从#tabela中选择Anexo,PN,总和(总计)AS总计
分组,按PN
DROP TABLE #tabela
谢谢!
这一次,我还在select语句中共享了一些条件,因为它超出了允许的最大字符数 评论部分。
声明@Anexo NVARCHAR(1)
声明@PN NVARCHAR(15)
声明@Nome NVARCHAR(100)
DECLARE @NIF NVARCHAR(10)
声明@CodIVA NVARCHAR(3)
声明@Total NUMERIC(19,6)
SET @DataDe = {?Data1}
SET @DataAte = {?Data2}
创建表#tabela(Anexo NVARCHAR(1),PN NVARCHAR(15),Nome NVARCHAR(100),NIF NVARCHAR(10),CodIVA NVARCHAR(3),总计NUMERIC(19,6))
DECLARE c1光标用于
SELECT'O',T20.CardCode,T20.CardName,(CASE SUBSTRING(T04.LicTradNum,3,9)时'THEN SUBSTRING(T20.LicTradNum,3,9)ELSE SUBSTRING(T04.LicTradNum,3 ,9)END),T06.Vatgroup,Sum((T06.LineTotal + T06.VatSum)* -1)来自ORIN T04内部联接RIN2 T06 ON T06.DocEntry = T04.DocEntry内部联接OCRD T20 ON T04.CardCode = T20 .CardCode WHERE T20.CardType ='O'AND T20.LicTradNum像'PT%'AND(@DataDe AND @DataAte之间的T04.DocDate)和isull(T06.Vatgroup,``)!=''AND(CASE SUBSTRING( T04.LicTradNum,3,9)当''THEN SUBSTRING(T20.LicTradNum,3,9)ELSE SUBSTRING(T04.LicTradNum,3,9)END)<>'999999990'GROUP BY T20.CardCode,T20.CardName, (案例SUBSTRING(T04.LicTradNum,3,9)则" THEN SUBSTRING(T20.LicTradNum,3,9)ELSE SUBSTRING(T04.LicTradNum,3,9)END),T06.Vatgroup
----- TRATA RIN3
全部联盟
SELECT'O',T20.CardCode,T20.CardName,(CASE SUBSTRING(T04.LicTradNum,3,9)当''THEN SUBSTRING(T20.LicTradNum,3,9)ELSE SUBSTRING(T04.LicTradNum,3 ,9)END),T07.Vatgroup,Sum((T07.LineTotal + T07.VatSum)* -1)来自ORIN T04内部联接RIN3 T07 ON T07.DocEntry = T04.DocEntry内部联接OCRD T20 ON T04.CardCode = T20 .CardCode WHERE T20.CardType ='O'AND T20.LicTradNum像'PT%'AND(@DataDe AND @DataAte之间的T04.DocDate)和isull(T07.Vatgroup,``)!=''AND(CASE SUBSTRING( T04.LicTradNum,3,9)当''THEN SUBSTRING(T20.LicTradNum,3,9)ELSE SUBSTRING(T04.LicTradNum,3,9)END)<>'999999990'GROUP BY T20.CardCode,T20.CardName, (当案例SUBSTRING(T04.LicTradNum,3,9)时,那么THEN SUBSTRING(T20.LicTradNum,3,9)ELSE SUBSTRING(T04.LicTradNum,3,9)END),T07.Vatgroup
全部联盟
SELECT'O',T20.CardCode,T20.CardName,(CASE SUBSTRING(T16.LicTradNum,3,9)时'THEN SUBSTRING(T20.LicTradNum,3,9)ELSE SUBSTRING(T16.LicTradNum,3) ,9)END),T18.Vatgroup,sum(isnull(T18.GrossValue,0)-isull(T18.Vatamount,0))来自JDT1 T16内部联接OCRD T20 ON T16.ShortName = T20.CardCode内部联接OJDT T17 ON T16.TransId = T17.TransId内部联接JDT1 T18开启T16.TransId = T18.TransId内部联接OVTG T19开启T18.VatGroup = T19。代码WHERE T20.CardType ='C'和T20.LicTradNum如'PT%'AND( @DataDe和@DataAte之间的T16.refdate)和T16.transtype ='30'和T16.ShortName!= T16.Account和T17.AutoVat ='Y'和T19.AcqstnRvrs ='Y'和T18.Credit <> 0 AND isull(T18.Vatgroup,'')!=''AND(案例SUBSTRING(T16.LicTradNum,3,9)当''THEN SUBSTRING(T20.LicTradNum,3,9)ELSE SUBSTRING(T16.LicTradNum,3, 9)END)<>'999999990'GROUP BY T20.CardCode,T20.CardName,(CASE SUBSTRING(T16.LicTradNum,3,9)when''THEN SUBSTRING(T20.LicTradNum,3,9)ELSE SUBSTRING(T16。 力克 radNum,3,9)END),T18.Vatgroup
打开c1
从c1下一步获取@ Anexo,@ PN,@ Nome,@ NIF,@ CodIVA,@ Total
@@ fetch_status <> -1
开始
插入#tabela(Anexo,PN,Nome,NIF,CodIVA,总计)
值(@ Anexo,@ PN,@ Nome,@ NIF,@ CodIVA,@ Total)
从c1下一步获取@ Anexo,@ PN,@ Nome,@ Nif,@ CodIVA,@ Total
结束
关闭c1
取消分配c1
从#tabela组选择Anexo,PN,Nome,NIF,CodIVA,SUM(总计)AS总计Anexo,PN,Nome,NIF,CodIVA
DROP TABLE #tabela
感谢您的帮助。 Florian Pfeffer
一周热门 更多>