All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g1201_1300.s1251_average_selling_price.script.sql Maven / Gradle / Ivy

There is a newer version: 1.30
Show newest version
# Write your MySQL query statement below
# #Easy #Database #2023_06_10_Time_1371_ms_(76.11%)_Space_0B_(100.00%)
SELECT p.product_id,
ROUND(SUM(p.price * u.units) / SUM(u.units), 2) AS average_price
FROM
Prices AS p
NATURAL JOIN
UnitsSold  AS u
WHERE
u.purchase_date BETWEEN p.start_date AND p.end_date
GROUP BY p.product_id;




© 2015 - 2024 Weber Informatics LLC | Privacy Policy