Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select typeid,name,sum(quantity)+(sum(perfect)*(0.25-(0.05*:pe))*max(base)) quantity from(
- select typeid,name,round(if(:me>=0,greatest(0,sum(quantity))+(greatest(0,sum(quantity))*((wastefactor/(:me+1))/100)),greatest(0,sum(quantity))+(greatest(0,sum(quantity))*(wastefactor/100)*(1-:ME)))) quantity,1 base,greatest(0,sum(quantity)) perfect from (
- select invTypes.typeid typeid,invTypes.typeName name,quantity
- from invTypes,invTypeMaterials
- where invTypeMaterials.materialTypeID=invTypes.typeID
- and invTypeMaterials.TypeID=:typeid
- union
- select invTypes.typeid typeid,invTypes.typeName name,
- invTypeMaterials.quantity*r.quantity*-1 quantity
- from invTypes,invTypeMaterials,ramTypeRequirements r,invBlueprintTypes bt
- where invTypeMaterials.materialTypeID=invTypes.typeID
- and invTypeMaterials.TypeID =r.requiredTypeID
- and r.typeID = bt.blueprintTypeID
- and r.activityID = 1 and bt.productTypeID=:typeid and r.recycle=1
- ) t join invBlueprintTypes on (invBlueprintTypes.productTypeID=:typeid) group by typeid,name
- union
- SELECT t.typeID typeid,t.typeName tn, r.quantity * r.damagePerJob quantity,0 base,r.quantity * r.damagePerJob perfect
- FROM ramTypeRequirements r,invTypes t,invBlueprintTypes bt,invGroups g
- where r.requiredTypeID = t.typeID and r.typeID = bt.blueprintTypeID
- and r.activityID = 1 and bt.productTypeID=:typeid and g.categoryID != 16
- and t.groupID = g.groupID) outside group by typeid,name
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement