0

I need to set up a calculated field that will calculate the price of a pizza order based on data in fields in other tables. I have a table that assigns each pizza a price and a code. From there, I want to calculate the price of an order in another table that only contains the Pizza Code and not the price of the pizza. I need to make it so that the Calculated Field in the table shows the price of the order based on the quantity of the pizza (that is also in the table) and the pizza code.

1 Answers1

0

if you want to calculate the total amount per order per pizza code try this:

select a.[#order],(a.quantity*b.price) as total,a.[pizza code] 
from tblorders a 
inner join tblpizza b 
on a.[pizza code]=b.[pizza code] 

if you want to calculate the total per order try this:

select a.[#order],sum(a.quantity*b.price) as total  
from tblorders a 
inner join tblpizza b on a.[pizza code]=b.[pizza code] 
group by a.[#order]
kostas
  • 461
  • 5
  • 13