/*
You are a data analyst working for a retail company. The company tracks product sales across different regions and wants to predict future revenue growth. The sales data is stored in the `sales_data` table.
Calculate the projected revenue for each product after applying a growth rate for the next 3 years.
Schema:
Table Name: `sales_data`
| Column Name | Data Type | Description |
|-------------------|-------------|---------------------------------------|
| product_id | INT | Unique identifier for each product |
| product_name | VARCHAR(50) | Name of the product |
| current_revenue | INT | Revenue generated in the current year |
| annual_growth_rate| FLOAT | Annual growth rate |
Task:
1. Calculate the projected revenue for each product after 3 years using the formula:
Projected Revenue = current_revenue * (1 + annual_growth_rate)^3
2. Display the following columns:
- `product_id`
- `product_name`
- `current_revenue`
- `annual_growth_rate`
- `projected_revenue`
Expected Output:
| product_id | product_name | current_revenue | annual_growth_rate | projected_revenue |
|------------|--------------|-----------------|---------------------|-------------------|
| 1 | Laptop | 50000 | 0.1 | 66550 |
| 2 | Smartphone | 30000 | 0.08 | 37791 |
| 3 | Tablet | 20000 | 0.05 | 23153 |
| 4 | Smartwatch | 15000 | 0.07 | 18376 |
| 5 | Desktop | 40000 | 0.09 | 51801 |
*/
CREATE TABLE sales_data (
product_id INT,
product_name VARCHAR(50),
current_revenue INT,
annual_growth_rate FLOAT
);
INSERT INTO sales_data (product_id, product_name, current_revenue, annual_growth_rate) VALUES
(1, 'Laptop', 50000, 0.10),
(2, 'Smartphone', 30000, 0.08),
(3, 'Tablet', 20000, 0.05),
(4, 'Smartwatch', 15000, 0.07),
(5, 'Desktop', 40000, 0.09);
SELECT
product_id,
product_name,
current_revenue,
annual_growth_rate,
ROUND(current_revenue * POWER(1 + annual_growth_rate, 3)) AS projected_revenue
FROM
sales_data;
To embed this program on your website, copy the following code and paste it into your website's HTML: