点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
嗨,
我们正在使用SAP B1,MS SQL 2012
有人帮助我生成以下格式的每日,每月,每年的销售分析报告。 来自应收发票
谢谢。
文档类型发票/贷记凭证文档编号 发布日期 客户/供应商代码 客户/供应商名称 商品及服务税编号 销售人员 BP组名称
BP参考号 付款条款代码 CGST SGST IGST LineTotal 货运 总计 备注发票
1716273 02/07/2018 C06508 CVR医疗系统37BCWPC4678P1ZI Nagaraji.N AP和TELUNGANA Whatsapp 5 2,124.00 17,400.00 200.00 19,724.00 xxx
具有日期范围的销售查询-------- >>>>>>
选择T0.docentry AS" SN",T0.DocNum [A/R号],T0。[Comments],T0。[DocStatus] AS" Status",T1.BaseDocNum作为'S/O No', 将CONVERT(VARCHAR(2),MONTH(T0.DocDate))用作月份,将DatePart(week,T0.DocDate)[周],将T0.DocDate作为"日期",将T0。[DocTime]作为"时间",T11。[ USER_CODE] AS'用户ID',T11。[U_NAME],T9。[SlpCode] AS" E. ID",T9.SlpName,T6.GroupName AS"贸易区",T22.WhsName [W/H名称],T0 .cardcode AS" BP代码",T0.CardName [BP名称],T1.Itemcode AS"项目代码",T8.ItmsGrpNam AS"家族",T1.Dscription [项目/服务描述],T0.GrosProfit AS" GP A /R"、(T1.Price-T1.StockPrice)[GP项目],T1.StockPrice,T1.Quantity [销售数量],T1.Price [销售价格],T1.LINETOTAL [销售价值],T1.GTotal AS "总销售额(+ IVA)",T1.LineTotal AS"净销售额(-IVA)",T1.LineVat AS" IVA值",((T1.LineVat/T1.LineTotal * 100))作为"%IVA", T1.GPTtlBasPr作为"股票价值",T1.GrssProfit作为"总利润",(((T1.GrssProfit/T1.LineTotal * 100))作为"%利润",T3。数量[返回数量],T3。价格[返回] 价钱 ],(T1.Quantity-T3.Quantity)[退货后的总数量],(T3.Price * T3.Quantity)[退货价值],((T1.Quantity * T1.Price)-(T3.Quantity * T1。 股票价格))[行毛利润],T3.GTotal AS"总销售回报",T3.LineTotal AS"净销售回报",T3.VatSum AS" IVA回报",T9.Commission AS"佣金百分比",(( T0.DocTotal-T0.VatSum)*(T9.Commission/100))作为"团队委员会",T10。[TrnspCode]作为"D。 ID",T10。[TrnspName] AS"驱动程序名称",T0。[Volume],T0。[Weight],(SELECT CASE ISNULL(CONVERT(NVARCHAR(MAX),T2.Cellular),'')时 ''ELSE ISNULL(CONVERT(NVARCHAR(MAX),T2.Cellular)+'','')END + CASE ISNULL(CONVERT(NVARCHAR(MAX),T2.Phone1),'')``然后''ELSE ISNULL(CONVERT(NVARCHAR(MAX),T2.Phone1)+'','')END + CASE ISNULL(CONVERT(NVARCHAR(MAX),T2.Phone2),'')``然后''ELSE ISNULL(CONVERT (NVARCHAR(MAX),T2.phone2)+'','')END)[客户电话],T5.NAME,T5.Address,T0.Address,T0.Address2来自OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry内部连接OCRD T2 ON T2.CardCode = T0.CARDCODE左外部连接OWHS T22 ON T22.WhsCode = T1.WhsCode左外部连接RIN1 T3 ON T1.DocEntry = T3.BaseEntry和T1.ObjType = T3。 AND T1.LineNum = T3.BaseLine左外连接ORIN T4上T3.DocEntry = T4.DocEntry左连接OCPR T5上T0.CntctCode = T5.CntctCode和T0.CARDCODE = T5.CARDCODE内连接OCRG T6上T2.GROUPCODE = T6.GROUPCODE内部联接OITM T7在T1.ITEMCODE = T7.I TEMCODE内连接OITB T8上T7.ItmsGrpCod = T8.ItmsGrpCod内连接OSLP T9上T0.SlpCode = T9.SlpCode左外连接OSHP T10上T0.TrnspCode = T10.TrnspCode内连接头T11上T0.UserSign = 其中T0.DocDate在[%1]和[%2]之间
月明智销售---------- >>>>>>
选择T0.ITEMCODE作为" AZ代码",T0。[CodeBars],T2.ItmsGrpNam作为"家族",T0.ItemName,T0.OnHand作为" AZ库存",(从中选择SUM(T1.QUANTITY) 带有(NOLOCK)的INV1 T1,其中T1.ITEMCODE = T0.ITEMCODE和YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'YTD',(从带有(NOLOCK)的INV1 T1中选择SUM(T1.QUANTITY) )MONTH(T1.DOCDATE)= 1和T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'JAN',(从INV1中选择SUM(T1.QUANTITY) T1的(NOLOCK)MONTH(T1.DOCDATE)= 2并且T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'FEB',(SELECT SUM(T1。 (INLOCK)的INV1 T1中的数量(MONTH(T1.DOCDATE)= 3和T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'MAR',(SELECT 来自INV1 T1的SUM(T1.QUANTITY),其中(NOLOCK)MONTH(T1.DOCDATE)= 4和T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'APR ',(在(NOLOCK)WHERE MONTH(T1.DOCDATE)= 5 AND T1.ITEMCODE的情况下从INV1 T1中选择SELECT SUM(T1.QUANTITY) = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'MAY',从(INLOCK)WHERE MONTH(T1.DOCDATE)= 6的INV1 T1中选择(SELECT SUM(T1.QUANTITY) AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'JUN',(从(#)在(#)的(#)中选择(NOLOCK)WHERE MONTH(T1。 DOCDATE)= 7 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'JUL',(在(NOLOCK)位置从INV1 T1中选择SUM(T1.QUANTITY) MONTH(T1.DOCDATE)= 8 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'AUG',(从INV1 T1中选择SUM(T1.QUANTITY) (NOLOCK)MONTH(T1.DOCDATE)= 9 AND T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'SEP',(SELECT SUM(T1.QUANTITY) 从INV1 T1(其中(NOLOCK))MONTH(T1.DOCDATE)= 10且T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)为'OCT',(SELECT SUM( INV1 T1中的(T1.QUANTITY)(NOLOCK)月(T1.DOCDATE)= 11并且T1.ITEMCODE = T0.ITEMCODE和YE AR(T1.DOCDATE)= YEAR(GETDATE())-0)为'NOV',从(INLOCK)从INV1 T1选择SUM(T1.QUANTITY),其中(MONTH)(T1.DOCDATE)= 12并且T1.ITEMCODE = T0.ITEMCODE AND YEAR(T1.DOCDATE)= YEAR(GETDATE())-0)从dbo.OITM T0左联接dbo.INV1 T1到T1.ItemCode = T0.ItemCode内联接OITB T2在T0上为'DEC'。 [ItmsGrpCod] = T2。[ItmsGrpCod]按T0.ItemCode,T2.ItmsGrpNam,T0。[CodeBars],T0.Itemname,T0.OnHand,YEAR(T1.DOCDATE)分组,年份(T1.DOCDATE)=年(GETDATE) ())-0 ORDER BY T0。 项目代码
一周热门 更多>