点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)专家们 Am有一个针对客...
点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)专家们 Am有一个针对客...
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
专家们
Am有一个针对客户老化的自定义报告的sql查询
它没有按照标准账龄报告向我返回正确的值
我为我的客户使用多币种,但需要以本地货币进行帐龄
我有一些领域
我还需要使用GlLicnumber过滤查询(在该查询中,我已经给了集合响应人名称)
任何人都可以帮助我编辑此查询并帮助我对其进行整理
致谢
SELECT tt。[Cust Num], tt。[客户名称], tt。[负责收款], tt。[余额], tt。[GroupCode], --tt。[上次收到付款], -tt。[上次收到付款日期], tt。[PymntGroup], --tt。[AliasName], tt。[city], --SUM(tt。[Credit Amt])AS [Credit Amt], SUM(tt。[0-30天])AS [0-30天], SUM(tt。[31至60天])AS [31至60天], SUM(tt。[61至90天])AS [61至90天], SUM(tt。[90至120天])AS [91至120天], SUM(tt。[121 Plus天])AS [121 Plus天] 来自( SELECT T1.CardCode AS'Cust Num', T1.CardName AS'客户名称', T1.GlblLocNum AS"负责收集", T0.BalDueDeb AS'Debit Amt', T0.BalDueCred * -1 AS'Credit Amt', T1.Balance AS" Balance", T1。[GroupCode], T2。[PymntGroup], --T1。[AliasName], T3。[城市], IsNull((从ORCT中选择前1个总和(DocTotal),其中ORCT.CardCode = T1.CardCode和ORCT.Status <>'C'和(ORCT.DocDate> = ORCT.DocDate和ORCT.DocDate <= ORCT.DocDate)组 通过ORCT.DocDate排序通过ORCT.DocDate DESC),0)'收到的最后付款', IsNull((从ORCT中选择前1个最大(DocDate),其中ORCT.CardCode = T1.CardCode和ORCT.Status <>'C'和(ORCT.DocDate> = ORCT.DocDate和ORCT.DocDate <= ORCT.DocDate)组 通过ORCT.DocDate排序通过ORCT.DocDate DESC),0)'最后一次收到付款日期', 案件 当T0.TransType = 13 THEN'AR Invoice' 当T0.TransType = 14时'AR Cred Memo' 当T0.TransType = 24然后"付款" ELSE"其他" END AS"转换类型", T0.Ref1 AS'参考', FcCurrency AS'货币', CONVERT(VARCHAR(10),RefDate,103)'过帐日期', CONVERT(VARCHAR(10),DueDate,103)'到期日', CONVERT(VARCHAR(10),TaxDate,103)'文档日期', 案件 当(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1 <30 THEN CASE 什么时候 Balduecred < > 0然后 Balduecred * -- 1个 其他 巴尔杜德 结束 以" 0-30天"结束, 案件 时间(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1> 30 AND(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1 <61 THEN 案件 当balduecred <> 0然后balduecred * -1 艾尔兹·巴尔杜德 结束 结束于" 31至60天", 案件 时间(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1> 60 AND(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1 <91 THEN 案件 当balduecred <> 0然后balduecred * -1 艾尔兹·巴尔杜德 结束 结束为" 61至90天", 案件 时间(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1> 90 AND(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1 <121 THEN 案件 当balduecred <> 0然后balduecred * -1 艾尔兹·巴尔杜德 结束 结束为" 90至120天", 案件 时间(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1> 121 THEN CASE 什么时候 Balduecred < > 0然后 Balduecred * -- 1个 其他 巴尔杜德 结束 结束于" 121天以上" 从JDT1 T0 内连接OCRD T1 开启T0.ShortName = T1.CardCode AND T1.CardType ='C'/* AND T1.QryGroup1 ='Y'*/ 内部联接OCTG T2 ON T1.GroupNum = T2.GroupNum 左外连接CRD1 T3在T1.City = T3.City 哪里 T1.CardType ='C'/* AND T1.CARDCODE NOT IN('DB00000063','JB00000145','RB00000465')*/AND T0.IntrnMatch ='0' AND T0.BalDueDeb!= T0.BalDueCred AND T1.Balance <>'0'/*和t1.CardCode ='RB0000117'*/和T1.GlblLocNum ='SAFDAR' )AS TT 通过...分组 tt。[Cust Num], tt。[客户名称], tt。[余额], tt。[GroupCode], tt。[上次收到的付款], tt。[上次收到付款日期], tt。[负责收款], tt。[PymntGroup], --tt。[AliasName] tt。[CITY] 按tt排序。[客户名称]
嗨,
尝试一下,
SELECT tt。[客户编号],tt。[客户名称],tt。[负责收款],tt。[余额],tt。[GroupCode],-tt。[收到的最后付款],- tt。[上次收到付款的日期],tt。[PymntGroup],-tt。[AliasName],tt。[city],SUM(tt。[Credit Amt])AS [Credit Amt],SUM(tt。[0 -30天])AS [0-30天],SUM(tt。[31至60天])AS [31至60天],SUM(tt。[61至90天])AS [61至90天] ,SUM(tt。[90至120天])AS [91至120天],SUM(tt。[121加天])AS [121加天]来自(选择t1.cardcode AS'Cust Num',t1。 cardname AS"客户名称",t1.glbllocnum AS"负责收款",t0.balduedeb AS"借方Amt",t0.balduecred * -1 AS" Credit Amt",t1.balance AS" Balance",t1。[GroupCode ],t2。[PymntGroup],--T1。[AliasName],T3。[City],IsNull((从ORCT中选择前1个总和(DocTotal),其中ORCT.CardCode = T1.CardCode和ORCT.Status <>'C '和(ORCT.DocDate> = ORCT.DocDate和ORCT.DocDate <= ORCT.DocDate)按ORCT.DocDate按ORCT.DocDate DESC排序),0)'最后收到的货款',IsNull((选择顶部1 来自ORCT的Max(DocDate)其中ORCT.CardCode = T1.CardCode和ORCT.Status <>'C'和(ORCT.DocDate> = ORCT.DocDate和ORCT.DocDate <= ORCT.DocDate)按ORCT.DocDate分组 ORCT.DocDate DESC),0)'上次收到付款日期',例T0.TransType = 13 THEN'AR发票'T0.TransType = 14 THEN'AR Cred Memo'当T0.TransType = 24 THEN'付款'ELSE '其他'END AS'转换类型',T0.Ref1 AS'参考',FcCurrency AS'货币',CONVERT(VARCHAR(10),RefDate,103)'过帐日期',CONVERT(VARCHAR(10),DueDate,103 )'Due Date',CONVERT(VARCHAR(10),TaxDate,103)'Doc Date',CASE WHEN(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1 <30 THEN CASE WALSE balduecred <> 0 THEN balduecred *-1 当(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1> 30 AND(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1 <61 THEN情况下,当Balduecred <> 0时,ELSE balduedeb END END结束为'0-30天' THEN balduecred * -1 ELSE balduedeb END END AS '31 to 60 Days',CASE WHEN(DATEDIFF(DD,RefDate,CURRENT_TIMEST AMP))+ 1> 60 AND(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1 <91 THEN CASE balduecred <> 0 THEN balduecred * -1 ELSE balduedeb END END AS '61 to 90 days',CASE WHEN(DATEDIFF) (DD,RefDate,CURRENT_TIMESTAMP))+ 1> 90 AND(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1 <121 THET CASE当balduecred <> 0 THEN balduecred * -1 ELSE balduedeb END AS '90至120天 ,CASE WHEN(DATEDIFF(DD,RefDate,CURRENT_TIMESTAMP))+ 1> 121 THEN的情况下balduecred <> 0 THEN balduedred *-1 ELSE balduedeb END END AS'121 Plus Days'from jdt1 T0 T0 INNER JOIN ocrd T1 on t0。 = t1.cardcode AND t1.cardtype ='C'/* AND T1.QryGroup1 ='Y'*/INNER JOIN octg T2 ON t1.groupnum = t2.groupnum INNER JOIN crd1 T3 ON t1.cardcode = t3.cardcode AND t1 .. [BillToDef] = t3。[地址] t1.cardtype ='C'/* AND T1.CARDCODE NOT IN('DB00000063','JB00000145','RB00000465')*/AND t0.intrnmatch ='0'AND t0.balduedeb!= t0.balduecred AND t1.balance <>'0')tt tt按tt。[Cust Num],tt。[Cust Nam e],tt。[Balance],tt。[GroupCode],tt。[收到上次付款],tt。[上次收到付款日期],tt。[负责收款],tt。[PymntGroup],--tt。 [AliasName] tt。[CITY]按tt。[客户名称]排序
此致
Nagarajan
一周热门 更多>