sql 采购订单明细

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 采购订单明细相关的知识,希望对你有一定的参考价值。

/**************************************************************

Purchase Order Details
	- Specify Date Range and Warehouse(s) below

***************************************************************/
SELECT PM.POID
	,PM.Warehouseid
	,DT.cal_week Order_week
	,CONVERT(DATE,PM.POOrderDate) Order_Date
	,CONVERT(DATE,PR.PORRecDate) Item_Received_Date
	,CONVERT(DATE,CASE WHEN PM.POCancelDate <> '1753-01-01' THEN PM.POCancelDate END ) Cancel_Date
	,ISNULL(CG.GroupName,'') Category_Group
	,IT.Category
	,IT.CUC
	,PD.PODItem Item
	,PD.PODPrice Unit_Cost
	,PD.podqty Orig_Order_Qty
	,PD.PODREQUESTQTY Modified_Order_Qty
	,ISNULL(PR.PORQty,0) Received_Qty
	,CASE WHEN POCancelDate = '1753-01-01' THEN PD.PODRequestQty ELSE ISNULL(PR.PORQty,0) END Expected_Qty
	,CASE WHEN PM.POOrigHL IN ('','H') THEN 'Stock'
		  WHEN PM.POOrigHL = 'L'	   THEN 'Single Piece'
		  WHEN PM.POOrigHL = 'P'	   THEN 'Preseason'
		  WHEN PM.POOrigHL = 'C'	   THEN 'Container'
		END Order_Type
	,V.VendorName Vendor
	,VP.VendorName VendorParent
FROM gxWizmo_24.dbo.POMASTER PM  -- PO Top Level Detail
	
	JOIN gxWizmo_24.dbo.POMASTERPODETAIL PD  -- PO Item Level Detail
	  ON PM.POID = PD.POID
	
	LEFT JOIN gxWizmo_24.dbo.PORECEIPT PR  -- PO Receiving Item Level Detail
	  ON PM.POID = PR.POID
	  AND PD.PODItem = PR.PORITEM	
	
	JOIN product_10.dbo.lu_item IT -- Item Info
	  ON PD.PODItem = IT.item
	
	LEFT JOIN product_10.dbo.CategoryGroup CG  -- Category Group Info
	  ON IT.category = CG.Category
	
	JOIN gxWizmo_24.dbo.VENDOR V  -- Vendor Info
	  ON PM.VendorID = V.VendorId
	
	JOIN gxWizmo_24.dbo.VENDOR VP  -- Vendor Info (Used for Parent Vendor)
	  ON V.VendorParentId = VP.VendorId
	
	JOIN misc_10.dbo.LU_DATE DT -- Date Info
	  ON CONVERT(DATE,PM.POOrderDate) = CONVERT(DATE,DT.cal_DATE)
WHERE PM.POOrderDate >= GETDATE() - 365		--> 1 Year of Data by default  -- Change Date Range here
	-- AND PM.Warehouseid IN ( 533	)			--> Warehouse Selection         -- Change Warehouse selection here
	-- AND V.VendorName like '%preseason%'
	-- AND CG.GroupName <> 'Fuel'	
	-- AND PM.POID = 12179962
ORDER BY POID DESC

以上是关于sql 采购订单明细的主要内容,如果未能解决你的问题,请参考以下文章

sql 采购订单明细

审核后采购订单修改单据明细补充

SAP中采购订单,如何删除?

模块分析总结

SQL从弱采购明细表中获取产品的最后采购价格

SAP 怎么从采购申请找到采购订单