|
 |
sql_language thread: Calculating Shipping Costs
Message #1 by tomlawton@f... on Thu, 12 Apr 2001 10:52:54
|
|
Hi Everyone,
I'm writing a script to calculate users shipping costs on the fly by
adding up the total weight of their order and then using this and the
destination zone to calculate the amount to be charged.
I've set up a Shipping table with the different zones as fields along the
top as below:
(Shipping_Weight)(Shipping_Zone1)(Shipping_Zone2)........
The shipping_weight field contains the weight ranges we can cater for.
What I want to do is pull just the price for that order out of the DB, is
there a way to do this using MIN as below (where 'zone' is the number of
destination zone, and 'orderWeight' is the total order weight):
strSQL = "SELECT MIN shipping_zone" & zone & " FROM shipping "&_
"WHERE Shipping_Weight > " & orderWeight & ";"
SET rsWeight = Con.Execute( strSQL )
Is this the way to use MIN to get the minimum Shipping weight above the
orderWeight. A similar result could be achieved by using the following
code, and just using the first record in the recordset but I presume this
has performance downsides:
strSQL = "SELECT shipping_zone" & zone & " FROM shipping "&_
"WHERE Shipping_Weight > " & orderWeight &_
"ORDER BY Shipping_weight ASC;"
SET rsWeight = Con.Execute( strSQL )
Is there a way to use the first method, or will I have to settle for the
second.
Thanks for any help
Tom
(Also approved on asp_databases by moderator)
|
|
 |