Sunday, March 11, 2012

displaying remaining records

Hello all. Quick rundown of what I need to do. I am pulling cartons(or
we can call them fruits) to make pallets of 25 cartons. Lets say there
is 27 apples in inventory, and i need to make a pallet of apples which
has room for 25. There is a remainder of 2 apples. 55 bananas in I am
doing this with various other fruits. I first need to pull out all all
units in which I can make a pallet(w/one fruit type on each). I then am
going to make pallets of any fruits that are left over
I just need to know the sql code to create a table from the remaining
fruits that cant make a full pallet, and the coding to pull 25 fruits
when available. I plan on doing the coding for the first using a
cursor. I am relatively new to SQL coding, and would appreciate the
help.I hope this is enough to get you started.
declare @.apples int
declare @.pallets int
declare @.cartonsPerPallet int
set @.apples = 127
set @.cartonsPerPallet = 25
set @.pallets = @.apples/@.cartonsPerPallet +
Sign(@.Apples%@.cartonsPerPallet)
print @.pallets|||Modification:
declare @.cartons int
declare @.pallets int
declare @.cartonsPerPallet int
set @.cartons = 125
set @.cartonsPerPallet = 25
set @.pallets = @.cartons/@.cartonsPerPallet +
Sign(@.cartons%@.cartonsPerPallet)
print @.pallets

No comments:

Post a Comment