Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Task Description:
- You have been given a DATABASE containing information about a company's sales. The database has two tables: sales and products.
- Table sales
- sale_id (integer): A unique identifier for each sale.
- product_id (integer): The ID of the product sold.
- quantity (integer): The quantity of the product sold in that particular sale.
- sale_date (date): The date of the sale.
- Table products
- product_id (integer): A unique identifier for each product.
- product_name (text): The name of the product.
- unit_price (decimal): The price of one unit of the product.
- Task Requirements:
- Write a SQL query to find the total revenue generated by each product in the year 2023. Sort the results in descending order by revenue. Your query should return the following columns:
- product_name (name of the product)
- total_revenue (the total revenue generated by the product in 2023)
- Additional Notes:
- You should only consider sales that occurred in the year 2023.
- The total revenue for each product can be calculated by multiplying the quantity by the unit_price for each sale.
Advertisement