sql 为Oracle编写的SQL代码,显示销售订单行信息。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 为Oracle编写的SQL代码,显示销售订单行信息。相关的知识,希望对你有一定的参考价值。

SELECT 
LINE.OPEN_FLAG open_Orders_only,  
HEADER.ORDER_NUMBER                    ORDER_NUMBER, 
LINE.LINE_NUMBER                       LINE_NUMBER, 
line.shipment_number				   shipment_number,
LINE.OPEN_FLAG,
DECODE(LINE.CUST_PO_NUMBER,NULL,  HEADER.CUST_PO_NUMBER,   LINE.CUST_PO_NUMBER)                CUST_PO_NUMBER, 
ITEMS.CONCATENATED_SEGMENTS            ITEM, 
ITEMS.DESCRIPTION                      ITEM_DESC, 
TRUNC(HEADER.BOOKED_DATE)              BOOKED_DATE, 
TRUNC(LINE.REQUEST_DATE)               REQUEST_DATE, 
TRUNC(LINE.SCHEDULE_SHIP_DATE)                SCHEDULE_SHIP_DATE, 
LINE.ORDER_QUANTITY_UOM                ORDER_UOM, 
ROUND(NVL(LINE.ORDERED_QUANTITY,0),2)  ORDER_QUANTITY, 
LINE.PRICING_QUANTITY_UOM              PRICING_UOM, 
ROUND(NVL(LINE.PRICING_QUANTITY,0),2)  PRICING_QUANTITY, 
LINE.ORDER_QUANTITY_UOM	               SHIPPING_UOM, 
ROUND(NVL(LINE.SHIPPED_QUANTITY,0),2)  	  	  	  SHIPPED_QUANTITY, 
ROUND(NVL(LINE.CANCELLED_QUANTITY,0),2)    CANCELLED_QUANTITY, 
NVL((SELECT SUM(md.primary_uom_quantity )
	   FROM APPS.mtl_demand md
		WHERE md.demand_source_line = line.line_id 
		AND md.inventory_item_id = line.inventory_item_id
		AND md.organization_id = line.ship_from_org_id
		AND md.demand_SOURCE_TYPE = 2 /* Sales Order MTL_SUPPLY_DEMAND_SOURCE_TYPE*/
		AND md.completed_quantity = 0 ),0)   RESERVED_QUANTITY,
 ROUND(NVL(LINE.FULFILLED_QUANTITY,0),2)    FULFILLED_QUANTITY, 
ROUND(NVL(NVL(LINE.ORDERED_QUANTITY,0) -        NVL(LINE.SHIPPED_QUANTITY,0),0),2)         UNFULFILLED_QUANTITY, 
ROUND(LINE.UNIT_SELLING_PRICE,2)           UNIT_SELLING_PRICE, 
ROUND(LINE.UNIT_LIST_PRICE,2)              UNIT_LIST_PRICE, 
LINE.INVOICE_INTERFACE_STATUS_CODE,
OOD.ORGANIZATION_CODE                      SHIP_FROM_ORG_CODE, 
SHIPTO_PARTY.PARTY_NAME                    SHIPTO_CUSTOMER, 
SHIPTO_CSUA.LOCATION                       SHIPTO_LOCATION, 
HEADER.FLOW_STATUS_CODE,
LINE.FLOW_STATUS_CODE ,
nvl((select  sum(primary_transaction_quantity )from  MTL_ONHAND_QUANTITIES_DETAIL moqd
    where moqd.inventory_item_id         = LINE.inventory_item_id 
    AND      moqd.organization_id            = LINE.ship_from_org_id ),0) ohq
FROM      APPS.OE_ORDER_HEADERS_ALL               HEADER, 
APPS.OE_ORDER_LINES_ALL                LINE, 
APPS.mtl_parameters       			OOD, 
APPS.MTL_SYSTEM_ITEMS_VL                ITEMS, 
APPS.HZ_CUST_SITE_USES_ALL              	SHIPTO_CSUA, 
APPS.HZ_CUST_ACCT_SITES_ALL             	SHIPTO_CASA, 
APPS.HZ_PARTY_SITES                    SHIPTO_PS, 
APPS.HZ_LOCATIONS                       SHIPTO_LOC,  
APPS.HZ_PARTIES                         SHIPTO_PARTY, 
APPS.HZ_CUST_ACCOUNTS_ALL                   SHIPTO_CA, 
APPS.HZ_CUST_ACCOUNTS_ALL                   SOLDTO_CA, 
APPS.HZ_PARTIES                      SOLDTO_PARTY, 
APPS.QP_LIST_HEADERS_B                 PL
WHERE   
 --header.org_id = 639 
OOD.ORGANIZATION_CODE='SKI'
and LINE.OPEN_FLAG ='Y'
--and LINE.FLOW_STATUS_CODE ='BOOKED'
and HEADER.HEADER_ID                    = LINE.HEADER_ID 
AND      LINE.SHIP_FROM_ORG_ID              = OOD.ORGANIZATION_ID 
AND      items.inventory_item_id         = LINE.inventory_item_id 
AND      items.organization_id            = LINE.ship_from_org_id 
AND   	 LINE.SHIP_TO_ORG_ID     =     		 SHIPTO_CSUA.SITE_USE_ID 
AND   	 SHIPTO_CSUA.CUST_ACCT_SITE_ID  = 	 SHIPTO_CASA.CUST_ACCT_SITE_ID   
AND   	 SHIPTO_CASA.PARTY_SITE_ID   = 		 SHIPTO_PS.PARTY_SITE_ID    
AND   	 SHIPTO_PS.LOCATION_ID    =  		 SHIPTO_LOC.LOCATION_ID     
AND   	 SHIPTO_PS.PARTY_ID     =     		 SHIPTO_PARTY.PARTY_ID 
AND   	 SHIPTO_PARTY.PARTY_ID     = 		 SHIPTO_CA.PARTY_ID  
AND   	 SHIPTO_CA.CUST_ACCOUNT_ID   =     	 SHIPTO_CASA.CUST_ACCOUNT_ID 
AND      LINE.SOLD_TO_ORG_ID                 = SOLDTO_CA.CUST_ACCOUNT_ID 
AND      SOLDTO_CA.PARTY_ID                  = SOLDTO_PARTY.PARTY_ID  
AND      PL.LIST_HEADER_ID (+)                  = LINE.PRICE_LIST_ID
AND 	 LINE.ITEM_TYPE_CODE 				 != 'CLASS'
order by 1,2,3


 	 

以上是关于sql 为Oracle编写的SQL代码,显示销售订单行信息。的主要内容,如果未能解决你的问题,请参考以下文章

每位员工每周佣金的 Oracle SQL

oracle数据库中编写sql语句后注释中文显示乱码如何解决,但是复制出来就显示中文

Oracle“Starts With”文本连接,不包括空值

求教写sql语句

SQL为每个部门选择最大销售额的日期[重复]

Oracle SQL 新手需要帮助查找类似记录