Forum Discussion
Sarah1983
Mar 21, 2020Copper Contributor
SQL Query problem
Good morning, I am fairly new to SQL. For a school project I have created a database with the purpose to calculate the cost of a recipe with products from a grocery store. My database looks as fol...
Sarah1983
Mar 21, 2020Copper Contributor
I found the solution to calculate the total cost:
select a.Recept_ID, a.Recept_Omschrijving, sum(b.Recept_Hoeveelheid * e.Prijs) as Kostprijsfrom Recept as ainner join ReceptProduct as bon a.Recept_ID = b.Recept_IDinner join Product as con b.Product_ID=C.Product_IDinner join VerpakkingProduct as don c.Product_ID = d.Product_IDinner join VerpakkingWinkel as eon d.Verpakking_ID=e.Verpakking_IDwhere a.Recept_ID = 1 and d.Verpakking_ID in (954,1994,2558,2981,3529,3595,4251,4440,4508,5383,5807,6109,6120,6204,6592,6802)group by a.Recept_ID, a.Recept_Omschrijving
I'm still searching for a solution to get the cheapest products back in the recipe cost query.