-- 作者:jackwin
-- 发布时间:2014/6/6 10:01:00
--
select b.c_id as 订单单据号, b.c_order_type as 订单类型, b.c_mk_dt as 订单制单日期, b.c_au_dt as 订单审核日期, b.c_cust_no as 客户编码 , c.c_name as 客户名称, cls1.c_name as 大类, cls2.c_name as 中类, cls3.c_name as 明细分类, a.c_barcode as 商品编码 , d.c_name as 商品名称, x.type as 产品类型, x.cgprice as 采购价, round(x.A13ML,4) AS A2013同类平均毛利率, round(x.A14cb,2) as A2014标准成本, a.c_model as 商品规格 , a.c_req_n as 订货数量 , a.c_rec_n as 实际出库, a.c_wprice as 目录价, a.c_fact_wprice as 实际售价 , a.c_at_order as 订货金额 , a.c_req_n*(a.c_wprice-a.c_fact_wprice) as 折扣金额, a.c_free_flag as 是否赠品 , case when ISNULL(c_req_n,0)-ISNULL(c_rec_n,0)>0 then \'部分收货\' when ISNULL(c_req_n,0)-ISNULL(c_rec_n,0)=0 then \'已完成\' when ISNULL(c_rec_n,0)=0 then \'尚未收货\' end as 订单商品收货状态, datepart(year,b.c_mk_dt) as 年度, datepart(MONTH,b.c_mk_dt) as 会计期 from newpro x left join tb_cust_orderg a(nolock) on x.pro_id=a.c_barcode left join tb_gds d(nolock) on a.c_gcode = d.c_gcode left join tb_cust_order b(nolock) on a.c_id = b.c_id left join tb_custinfo c(nolock) on b.c_cust_no = c.c_no left join tb_user e(nolock) on b.c_mk_userno = e.c_userno left join tb_gdsclass cls(nolock) on left(d.c_ccode,1)=cls.c_ccode left join tb_gdsclass cls1(nolock) on left(d.c_ccode,2)=cls1.c_ccode left join tb_gdsclass cls2(nolock) on left(d.c_ccode,4)=cls2.c_ccode left join tb_gdsclass cls3(nolock) on left(d.c_ccode,6)=cls3.c_ccode where b.c_status<>\'已作废\' and b.c_order_type<>\'手工退货\' and b.c_mk_dt>\'2013-12-31\' order by b.c_id
|