Average Selling Price using join sum round functions date between SQL MySQL leetcode solution

Опубликовано: 05 Май 2024
на канале: CodeWis Technologies by Nuhman Paramban
6
0

Calculate the average selling price for each product considering price changes over time.

Data Provided:

Prices Table:
Columns:
product_id (int): Unique identifier for a product.
start_date (date): Start date of a specific price period for the product.
end_date (date): End date of the specific price period for the product. (No overlapping periods for the same product exist)
price (int): Price of the product during the specified period.
UnitsSold Table:
Columns:
product_id (int): Unique identifier for a product.
purchase_date (date): Date a specific product unit was sold.
units (int): Number of units sold on the purchase date.
Desired Output:

A table named average_price with the following columns:

product_id (int): Unique identifier for a product (same as input tables).
average_price (float): Average selling price for the product, rounded to 2 decimal places.

Explanation:

Average selling price for a product is calculated by dividing the total revenue generated from the product by the number of units sold.
Consider price changes over time by using the price applicable on the purchase date for each unit sold.

SQL MySQL JOIN USING SUM ROUND DATE BETWEEN leetcode problem and solution


Смотрите видео Average Selling Price using join sum round functions date between SQL MySQL leetcode solution онлайн, длительностью часов минут секунд в хорошем качестве, которое загружено на канал CodeWis Technologies by Nuhman Paramban 05 Май 2024. Делитесь ссылкой на видео в социальных сетях, чтобы ваши подписчики и друзья так же посмотрели это видео. Данный видеоклип посмотрели 6 раз и оно понравилось 0 посетителям.