Sale Prices
You're running an e-commerce website called "Wamazon".
You have a table of the products you sell called merchandise.
| column_name | type |
|---|---|
id | INTEGER |
name | VARCHAR |
price_usd | NUMERIC |
discount_perc | NUMERIC |
You have the original price of each item in the price_usd column.
Some of these items are on sale!
We need to display the price after applying the discount.
The items on sale have a non-zero value in the discount_perc column, which is the percentage to reduce the original price.
A discount of 0% is essentially not on sale.
We aren't sure why some items have NULL for the discount_perc and some have 0%, but let's treat them as the same.
Use these 2 columns to compute the sale price of each item.
Because this is a dollar amount, make sure to round to 2 decimal places.
You can use round(numeric, 2) for this.
You can read more about this function in the Postgres documentation.
Also, select the name of each product.