473,320 Members | 1,936 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to distribute a value base on table

Hi,

I have given a task but i have no idea on it.. it sound simple but in store procedure i can't have a clue at all.

Table Water
NameOfWater VARCHAR,
WaterAmount INT

Table Cup
Id int,
CupName VARCHAR,
Cup1Space INT,
Cup2Space INT

Table Report
CupName VARCHAR,
NameOfWater VARCHAR,
Cup_Cup1Space INT,
Cup_Cup2Space INT

Value in Water table
Pepsi, 60
Sprite, 300
Pepsi, 60

Value in Cup table
1, SmallCup, 50, 20
2, MediumCup, 110, 20
3, LargeCup, 500, 500

Logic
We place the total amount of same water into Cup1Space until max then follow by Cup2Space, and balance will move to next Cup(order by cup id) of Cup1Space then follow by Cup2Space until the amount is completely place

So, the final Report table will look like this
SmallCup, Pepsi, 50, 20 (from 120 distribute 70 left 50)
MediumCup, Pepsi, 50, 0 (medium cup having enuf space for 50)
LargeCup, Pepsi, 0, 0 (Useless since is nothing inside the cup, can discard)
SmallCup, Sprite, 50, 20 (from 300 distribute 70 left 230)
MediumCup, Sprite, 110, 20 (from 230 distribute 130 left 100)
LargeCup, Sprite, 100, 0 (large cup will have enuf space)

Anyone plz help.

Regards,
Hooked888
Jul 9 '07 #1
0 905

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: cwizard | last post by:
I'm calling on a function from within this form, and there are values set but every time it gets called I get slammed with a run time error... document.frmKitAmount.txtTotalKitValue is null or not...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
4
by: Jeff Boes | last post by:
(I thought I posted this yesterday from Google Groups, but it doesn't appear to have "taken".) I'm having a problem with a rule designed to log new rows inserted into one table. The base table...
1
by: Eric E | last post by:
Hi, I'm trying to write a recordset-returning function that returns a values from a base table, and one column from a joined table, where the joined table varies according to a field of the base...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
5
by: Jacko7289 | last post by:
Happy New Year good folks, Need your expertise on this matter. I've got an ORDER Table which is populated with data from ORDER Form. In my form, a text box looks up for a value (Base cost) in...
15
by: gunnar.sigurjonsson | last post by:
I´m having some problem retrieving identity value from my newly inserted row into a view. I have two tables T1 and T2 which I define as following CREATE TABLE T1 ( id BIGINT GENERATED ALWAYS...
28
by: Zeeshan7 | last post by:
I use following code to distribute accounts equally to employees from table "Assign" to table "Accounts". The code update one by one 'EmpID' from table "Assign" to field ‘EmployeeID’ in table...
0
by: Martin Honnen | last post by:
kishjeff wrote: Add parentheses e.g (base-uri($d),(tokenize(base-uri($d), '/'), '', ) --
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.