您的位置:首页 > 数据库

将行数据转到列显示的sql例子

2010-06-18 13:02 218 查看
select
a.forecast_year "提报年",
a.forecast_cycle_number "提报周",
c.PRODUCT_LINE_NAME "产品线",
b.product_code "产品编码",
b.product_sname "产品名称",
max(decode(b.forecast_ver,-1,b.PARAMETER_1)) "T-1周销量" ,
max(decode(b.forecast_ver,-1,b.PARAMETER_2)) "T-1周上推5周平均销量" ,
max(decode(b.forecast_ver,-1,b.FORECAST_REF_FINAL_STOCK)) "T-1周期末库存" ,
max(decode(b.forecast_ver,-1,b.PARAMETER_10)) "T-1周库存周转天数" ,

max(decode(b.forecast_ver,0,b.FORECAST_REF_PLAN_ARRIVE)) "T周确认到货" ,
max(decode(b.forecast_ver,0,b.forecast_retail_input)) "T周零售预测" ,
max(decode(b.forecast_ver,0,b.FORECAST_REF_FINAL_STOCK)) "T周期末库存" ,
max(decode(b.forecast_ver,0,b.PARAMETER_10)) "T周库存周转天数" ,

max(decode(b.forecast_ver,1,b.FORECAST_REF_PLAN_ARRIVE)) "T+1周确认到货" ,
max(decode(b.forecast_ver,1,b.forecast_retail_input)) "T+1周零售预测" ,
max(decode(b.forecast_ver,1,b.FORECAST_REF_FINAL_STOCK)) "T+1周期末库存" ,
max(decode(b.forecast_ver,1,b.PARAMETER_10)) "T+1周库存周转天数" ,

max(decode(b.forecast_ver,2,b.PARAMETER_11)) "T+2周评审后预测" ,
max(decode(b.forecast_ver,2,b.forecast_retail_input)) "T+2周零售预测" ,
max(decode(b.forecast_ver,2,b.FORECAST_REF_FINAL_STOCK)) "T+2周期末库存" ,
max(decode(b.forecast_ver,2,b.PARAMETER_10)) "T+2周库存周转天数" ,

max(decode(b.forecast_ver,3,b.FORECAST_REF_PLAN)) "T+3周计划数" ,
max(decode(b.forecast_ver,3,b.forecast_demand_input)) "T+3周需求预测" ,
max(decode(b.forecast_ver,3,b.forecast_retail_input)) "T+3周零售预测" ,
max(decode(b.forecast_ver,3,b.FORECAST_REF_FINAL_STOCK)) "T+3周期末库存" ,
max(decode(b.forecast_ver,3,b.PARAMETER_10)) "T+3周库存周转天数" ,
max(decode(b.forecast_ver,3,b.PARAMETER_12)) "T+3周周转天数下限" ,
max(decode(b.forecast_ver,3,b.PARAMETER_13)) "T+3周周转天数上限" ,

max(decode(b.forecast_ver,4,b.FORECAST_REF_PLAN)) "T+4周计划数" ,
max(decode(b.forecast_ver,4,b.forecast_demand_input)) "T+4周需求预测" ,
max(decode(b.forecast_ver,4,b.forecast_retail_input)) "T+4周零售预测" ,

max(decode(b.forecast_ver,5,b.FORECAST_REF_PLAN)) "T+5周计划数" ,
max(decode(b.forecast_ver,5,b.forecast_demand_input)) "T+5周需求预测" ,
max(decode(b.forecast_ver,5,b.forecast_retail_input)) "T+5周零售预测" ,

max(decode(b.forecast_ver,6,b.FORECAST_REF_PLAN)) "T+6周计划数" ,
max(decode(b.forecast_ver,6,b.forecast_demand_input)) "T+6周需求预测" ,
max(decode(b.forecast_ver,6,b.forecast_retail_input)) "T+6周零售预测"

from ecc_fst.forecast_collect_title a,
ecc_fst.forecast_collect_DETAIL b,
ecc_fnd.product_line_v c
where a.forecast_collect_title_id = b.forecast_collect_title_id
and a.forecast_year = 2010
and a.forecast_cycle_number=24
and a.product_line_id = c.PRODUCT_ID
and a.fst_role_lookup_code='PR'
and a.fact_submit_customer_code = 'B0004854'
and b.forecast_ver>=-1
group by
a.forecast_collect_title_id,
a.forecast_year,
a.forecast_cycle_number,
c.PRODUCT_LINE_NAME,
b.product_code,
b.product_sname
order by a.forecast_collect_title_id,b.product_code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐