|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
下面代码里的颜色部分希望有一个变量替代:
SELECT scd.标记1,scd.生产单号,cpbm.分类,scd.产品编码,scd.描述,scd.材料,scd.颜色,scd.下单数量,scd.生产分厂,scd.单价,scd.总金额 as 产值,
cpgzde.配料单价,
cpgzde.配料单价*case when cpbm.分类 ='C' or cpbm.分类 ='C2' then
case when scd.下单数量<=40 then 2
when scd.下单数量>40 and scd.下单数量<=60 then 80
when scd.下单数量>60 and scd.下单数量<=80 then 1.3
when scd.下单数量>80 and scd.下单数量<=104 then 104
when scd.下单数量>104 and scd.下单数量<=200 then 1
when scd.下单数量>200 and scd.下单数量<=1000 then 200
when scd.下单数量>1000 then 0.95 end
else
case when scd.下单数量<=10 then 2
when scd.下单数量>10 and scd.下单数量<=15 then 20
when scd.下单数量>15 and scd.下单数量<=20 then 1.3
when scd.下单数量>20 and scd.下单数量<=26 then 26
when scd.下单数量>26 and scd.下单数量<=50 then 1
when scd.下单数量>50 and scd.下单数量<=55 then 50
when scd.下单数量>55 and scd.下单数量<=85 then 0.9
when scd.下单数量>85 and scd.下单数量<=90 then 77
when scd.下单数量>90 and scd.下单数量<=150 then 0.85
when scd.下单数量>150 and scd.下单数量<=160 then 128
when scd.下单数量>160 then 0.8 end
end as 配料工资,
cpgzde.机加单价,
cpgzde.机加单价*case when cpbm.分类 ='C' or cpbm.分类 ='C2' then
case when scd.下单数量<=40 then 2
when scd.下单数量>40 and scd.下单数量<=60 then 80
when scd.下单数量>60 and scd.下单数量<=80 then 1.3
when scd.下单数量>80 and scd.下单数量<=104 then 104
when scd.下单数量>104 and scd.下单数量<=200 then 1
when scd.下单数量>200 and scd.下单数量<=1000 then 200
when scd.下单数量>1000 then 0.95 end
else
case when scd.下单数量<=10 then 2
when scd.下单数量>10 and scd.下单数量<=15 then 20
when scd.下单数量>15 and scd.下单数量<=20 then 1.3
when scd.下单数量>20 and scd.下单数量<=26 then 26
when scd.下单数量>26 and scd.下单数量<=50 then 1
when scd.下单数量>50 and scd.下单数量<=55 then 50
when scd.下单数量>55 and scd.下单数量<=85 then 0.9
when scd.下单数量>85 and scd.下单数量<=90 then 77
when scd.下单数量>90 and scd.下单数量<=150 then 0.85
when scd.下单数量>150 and scd.下单数量<=160 then 128
when scd.下单数量>160 then 0.8 end
end as 机加工资,
cpgzde.砂光单价,
cpgzde.砂光单价*case when cpbm.分类 ='C' or cpbm.分类 ='C2' then
case when scd.下单数量<=40 then 2
when scd.下单数量>40 and scd.下单数量<=60 then 80
when scd.下单数量>60 and scd.下单数量<=80 then 1.3
when scd.下单数量>80 and scd.下单数量<=104 then 104
when scd.下单数量>104 and scd.下单数量<=200 then 1
when scd.下单数量>200 and scd.下单数量<=1000 then 200
when scd.下单数量>1000 then 0.95 end
else
case when scd.下单数量<=10 then 2
when scd.下单数量>10 and scd.下单数量<=15 then 20
when scd.下单数量>15 and scd.下单数量<=20 then 1.3
when scd.下单数量>20 and scd.下单数量<=26 then 26
when scd.下单数量>26 and scd.下单数量<=50 then 1
when scd.下单数量>50 and scd.下单数量<=55 then 50
when scd.下单数量>55 and scd.下单数量<=85 then 0.9
when scd.下单数量>85 and scd.下单数量<=90 then 77
when scd.下单数量>90 and scd.下单数量<=150 then 0.85
when scd.下单数量>150 and scd.下单数量<=160 then 128
when scd.下单数量>160 then 0.8 end
end as 砂光工资,
cpgzde.组装单价,
cpgzde.组装单价*case when cpbm.分类 ='C' or cpbm.分类 ='C2' then
case when scd.下单数量<=40 then 2
when scd.下单数量>40 and scd.下单数量<=60 then 80
when scd.下单数量>60 and scd.下单数量<=80 then 1.3
when scd.下单数量>80 and scd.下单数量<=104 then 104
when scd.下单数量>104 and scd.下单数量<=200 then 1
when scd.下单数量>200 and scd.下单数量<=1000 then 200
when scd.下单数量>1000 then 0.95 end
else
case when scd.下单数量<=10 then 2
when scd.下单数量>10 and scd.下单数量<=15 then 20
when scd.下单数量>15 and scd.下单数量<=20 then 1.3
when scd.下单数量>20 and scd.下单数量<=26 then 26
when scd.下单数量>26 and scd.下单数量<=50 then 1
when scd.下单数量>50 and scd.下单数量<=55 then 50
when scd.下单数量>55 and scd.下单数量<=85 then 0.9
when scd.下单数量>85 and scd.下单数量<=90 then 77
when scd.下单数量>90 and scd.下单数量<=150 then 0.85
when scd.下单数量>150 and scd.下单数量<=160 then 128
when scd.下单数量>160 then 0.8 end
end as 组装工资,
cpgzde.油漆单价,case when scd.生产分厂 = 'N2' then 1.5 when scd.生产分厂 = 'N3' and cpbm.分类 = 'T' then 1.5 else 1 end as 油漆系数,
cpgzde.油漆单价*case when cpbm.分类 ='C' or cpbm.分类 ='C2' then
case when scd.下单数量<=40 then 2
when scd.下单数量>40 and scd.下单数量<=60 then 80
when scd.下单数量>60 and scd.下单数量<=80 then 1.3
when scd.下单数量>80 and scd.下单数量<=104 then 104
when scd.下单数量>104 and scd.下单数量<=200 then 1
when scd.下单数量>200 and scd.下单数量<=1000 then 200
when scd.下单数量>1000 then 0.95 end
else
case when scd.下单数量<=10 then 2
when scd.下单数量>10 and scd.下单数量<=15 then 20
when scd.下单数量>15 and scd.下单数量<=20 then 1.3
when scd.下单数量>20 and scd.下单数量<=26 then 26
when scd.下单数量>26 and scd.下单数量<=50 then 1
when scd.下单数量>50 and scd.下单数量<=55 then 50
when scd.下单数量>55 and scd.下单数量<=85 then 0.9
when scd.下单数量>85 and scd.下单数量<=90 then 77
when scd.下单数量>90 and scd.下单数量<=150 then 0.85
when scd.下单数量>150 and scd.下单数量<=160 then 128
when scd.下单数量>160 then 0.8 end
end *
case when scd.生产分厂 = 'N2' then 1.5 when scd.生产分厂 = 'N3' and cpbm.分类 = 'T' then 1.5 else 1 end
as 油漆工资,
cpgzde.装配单价,
cpgzde.装配单价*case when cpbm.分类 ='C' or cpbm.分类 ='C2' then
case when scd.下单数量<=40 then 2
when scd.下单数量>40 and scd.下单数量<=60 then 80
when scd.下单数量>60 and scd.下单数量<=80 then 1.3
when scd.下单数量>80 and scd.下单数量<=104 then 104
when scd.下单数量>104 and scd.下单数量<=200 then 1
when scd.下单数量>200 and scd.下单数量<=1000 then 200
when scd.下单数量>1000 then 0.95 end
else
case when scd.下单数量<=10 then 2
when scd.下单数量>10 and scd.下单数量<=15 then 20
when scd.下单数量>15 and scd.下单数量<=20 then 1.3
when scd.下单数量>20 and scd.下单数量<=26 then 26
when scd.下单数量>26 and scd.下单数量<=50 then 1
when scd.下单数量>50 and scd.下单数量<=55 then 50
when scd.下单数量>55 and scd.下单数量<=85 then 0.9
when scd.下单数量>85 and scd.下单数量<=90 then 77
when scd.下单数量>90 and scd.下单数量<=150 then 0.85
when scd.下单数量>150 and scd.下单数量<=160 then 128
when scd.下单数量>160 then 0.8 end
end as 装配工资,
cpgzde.包装单价,
cpgzde.包装单价*case when cpbm.分类 ='C' or cpbm.分类 ='C2' then
case when scd.下单数量<=40 then 2
when scd.下单数量>40 and scd.下单数量<=60 then 80
when scd.下单数量>60 and scd.下单数量<=80 then 1.3
when scd.下单数量>80 and scd.下单数量<=104 then 104
when scd.下单数量>104 and scd.下单数量<=200 then 1
when scd.下单数量>200 and scd.下单数量<=1000 then 200
when scd.下单数量>1000 then 0.95 end
else
case when scd.下单数量<=10 then 2
when scd.下单数量>10 and scd.下单数量<=15 then 20
when scd.下单数量>15 and scd.下单数量<=20 then 1.3
when scd.下单数量>20 and scd.下单数量<=26 then 26
when scd.下单数量>26 and scd.下单数量<=50 then 1
when scd.下单数量>50 and scd.下单数量<=55 then 50
when scd.下单数量>55 and scd.下单数量<=85 then 0.9
when scd.下单数量>85 and scd.下单数量<=90 then 77
when scd.下单数量>90 and scd.下单数量<=150 then 0.85
when scd.下单数量>150 and scd.下单数量<=160 then 128
when scd.下单数量>160 then 0.8 end
end as 包装工资,
case when cpbm.分类 ='C' or cpbm.分类 ='C2' then
case when scd.下单数量<=40 then 2
when scd.下单数量>40 and scd.下单数量<=60 then 80
when scd.下单数量>60 and scd.下单数量<=80 then 1.3
when scd.下单数量>80 and scd.下单数量<=104 then 104
when scd.下单数量>104 and scd.下单数量<=200 then 1
when scd.下单数量>200 and scd.下单数量<=1000 then 200
when scd.下单数量>1000 then 0.95 end
else
case when scd.下单数量<=10 then 2
when scd.下单数量>10 and scd.下单数量<=15 then 20
when scd.下单数量>15 and scd.下单数量<=20 then 1.3
when scd.下单数量>20 and scd.下单数量<=26 then 26
when scd.下单数量>26 and scd.下单数量<=50 then 1
when scd.下单数量>50 and scd.下单数量<=55 then 50
when scd.下单数量>55 and scd.下单数量<=85 then 0.9
when scd.下单数量>85 and scd.下单数量<=90 then 77
when scd.下单数量>90 and scd.下单数量<=150 then 0.85
when scd.下单数量>150 and scd.下单数量<=160 then 128
when scd.下单数量>160 then 0.8 end
end as 批量系数
FROM scd,cpgzde,cpbm
WHERE cpbm.产品编码 = scd.产品编码
and scd.产品编码 = cpgzde.产品编码
order by scd.生产单号,scd.顺号 |
|