Jump to content

Help with Math Op's in SQL, please


miffe

Recommended Posts

I have the next 3 tables (In an Access .mdb DB):

   (Products):--------------------idProduct | name--------------------1		   E-Ring-12		   E-Ring-23		   F-Ring-1   (Resources):--------------------------------------------idResource | name   | baseCost | formula--------------------------------------------1			gold	 60		 * 1.22			silver   30		 * 3 + 23			0.10CT   90		 * 1.2 + .104			0.12CT   110		* 1.2 + .12 (ProductsResources):----------------------idProduct | idResource----------------------1		   12		   12		   33		   13		   4

So in the first table I have a list of products, in the second one I have a list of resources used to make products like gold, diamonds, etc... and each one of these has a different price and a formula. So I have an extra table to relate the products to the resources, 1-1, 1-2, 2-1, 2-5, etc...The problem: All the resources used for each product have a base price, the price they are originally bought at, and I use a formula to calculate how much goes into each product to give me a final 'sell price'. If there was one sell price for all the resources I could use a simple query with the operation stated there, but there is different operations for each resource.What I need is a Query (that'll work in Access) that will calculate the sum of all the final prices for the resources in a product.Example:Product "1" has resources "1, 3, 5"... these resources cost originally "5, 10, 15" dollars, and i want the sell price to be at "price * 1.2, price * 1.5, price * price" for them all. The total price for the product "1" would be the sum of " (5*1.2) + (10*1.5) + (15*15) " in this case... I want to be able to display the result for this with a Select...Any suggestions on how to make this query in access SQL format?Thanks in advance, Miffe

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...