Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Weights Table

Author  Topic 

Steve2106
Posting Yak Master

183 Posts

Posted - 2010-03-30 : 10:03:17
Hello,

Can someone help me please.
I have a site and I have been asked by the client if I can add a postage cost based on the weight of the item(s
I need to create a table that will help do the calculation. I need to be able to select the correct record based on the weight calculation from the items chosen.).(I can already get the weight total)
So if the user picks 3 items with a combined weight of say 7.45kg, in the new table I need to have something like:
0 - 0.99kg £ 2.40
1 - 2.99kg £ 3.80
3 - 5.99kg £ 6.20
6 - 8.99kg £ 8.80

as the combined weight of my items is 7.45kg the select command will return £ 8.80. If the combined weight was 4.20kg it would return 6.20

How would I design the table I need and how would I write the select statement to select the right record based on the total weight.

Thanks for any help you can give I really appreciate it.

Best Regards,



Steve

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-30 : 10:21:05
Table WeightCost
id int (an identity column I would say)
Weight_from int (weight in gram)
Weight_to int (weight in gram)
Cost money (or whatever)

select Cost from WeightCost
where your_weight_in_gram between Weight_from and Weight_to


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-30 : 10:22:31
Duplicate Post
Don't do that!

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=142253


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -