select h.CUSTOMER_PO_NUMBER as 客户PO, h.ORDER_NUMBER as 生产编号, ooot.ORDER_TYPE_NAME as 订单类型, v.ACCOUNT_SHORT_NAME as 客户简称, atts.suit_count as 套数, h.order_status as 订单状态, h.order_progress as 订单进展, to_char(h.creation_date,'yyyy-mm-dd')as 订单创建日期, to_char(h.BOOKED_DATE,'yyyy-mm-dd') as 订单受理日期, to_char(h.complete_date,'yyyy-mm-dd') as 订单完工日期, to_char(l.delivery_date,'yyyy-mm-dd') as 订单发货日期, tv.meaning1 as 大区, tv.meaning2 as 省区, tv.meaning3 as 片区, tv.MEANING as 城市, v.ACCOUNT_NUMBER as 客户编号, atts.STYLE_SERIES as 订单风格, atts.PROMOTION_HEADER_ID as 促销活动, --SUM(decode(l.item_class,'MM',nvl(l.UNIT_PRICE,0) ,0)) AS 木门, --木门 count(case when l.item_class='MM' then l.UNIT_PRICE else null end) as 木门 from APPS.OMS_OE_ORDER_HEADERS h, APPS.OMS_OE_ORDER_TYPES ooot, apps.cux_om_order_headers_v v, APPS.OMS_OE_ORDER_HEADER_ATTS atts, apps.mdm_cust_territory_solutions_v tv, APPS.OMS_OE_ORDER_LINES l where 1=1 ${if(len(订单类型)==0,"","and ooot.ORDER_TYPE_NAME='"+订单类型+"'")} ${if(len(订单编号)==0,"","and h.ORDER_NUMBER='"+订单编号+"'")} ${if(len(po)==0,"","and h.CUSTOMER_PO_NUMBER='"+po+"'")} ${if(len(客户简称)==0,"","and v.ACCOUNT_SHORT_NAME='"+客户简称+"'")} ${if(len(sq)==0,"","and tv.meaning2 in ('"+sq+"')")} ${if(len(BookDates)=0,""," and to_char(h.BOOKED_DATE,'yyyy-mm-dd')>='"+BookDates+"'")} ${if(len(BookDatee)=0,""," and to_char(h.BOOKED_DATE,'yyyy-mm-dd') ${if(len(BookDatee_c)=0,""," and to_char(h.creation_date,'yyyy-mm-dd')<='"+BookDatee_c+"'")} and v.order_type_id=ooot.order_type_id and ooot.order_type_id=h.order_type_id and h.header_id=atts.header_id and atts.header_id=v.header_id and v.header_id=l.header_id and h.UNIT_ID=tv.UNIT_ID and tv.UNIT_ID=ooot.UNIT_ID and ooot.UNIT_ID=v.UNIT_ID and v.UNIT_ID=l.UNIT_ID and h.ACCOUNT_SITE_ID=v.ACCOUNT_SITE_ID and h.TERRITORY_ID=v.TERRITORY_ID and v.TERRITORY_ID=tv.TERRITORY_ID --and ooot.CREATED_BY=atts.CREATED_BY group by h.CUSTOMER_PO_NUMBER , h.ORDER_NUMBER , ooot.ORDER_TYPE_NAME , v.ACCOUNT_SHORT_NAME, atts.suit_count, h.order_status, h.order_progress, h.creation_date, h.BOOKED_DATE, h.complete_date, tv.meaning2, l.delivery_date, tv.meaning1, tv.meaning3, tv.MEANING, v.ACCOUNT_NUMBER, atts.STYLE_SERIES, atts.PROMOTION_HEADER_ID |