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 2000 Forums
 SQL Server Development (2000)
 SQL tatement that is way too complex for me!

Author  Topic 

Nick
Posting Yak Master

155 Posts

Posted - 2001-10-16 : 10:22:10
I hope someone can help me. I need to write a SQL statement that determines the handling cost for all orders placed in a month. The handling cost is determined by a fix cost per box + a fix cost for each item within the box. So to determine the handling cost of an order the formula would be

(NumBoxes * CostPerBox) + (NumItems * CostPerItem)

The catch is that there is a maximum charge per box. For example if the cost per box is six dollars, the cost per item is .25, and the maximum box charge is 10 dollars. If a box has more than sixteen items it will still only cost 10 dollars.

The handling cost should be determinable from the table tblBoxes. It has fields boxID (which is an nvarchar -- the orderID-hyphen-the number of the box. For instance 6240-1, 6240-2 for order 6240) orderID, numberItmes, dateShipped.

tblCustomers has a field maxBoxCharge

Can anyone give me some help? I'm using SQL Server 2000 and ultimately trying to put this in a stored procedure. Hope this makes sense.. Thanks!

   

- Advertisement -