Ctr

Sale Prices

You're running an e-commerce website called "Wamazon". You have a table of the products you sell called merchandise.


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.

© 2022 Andrew Carlson. All rights reserved.

name
VARCHAR
sale_price
NUMERIC
1
Licensed Frozen Mouse
68.39
2
Modern Bronze Computer
15.00
3
Awesome Bronze Chicken
47.95
4
Licensed Frozen Bike
10.00
5
Awesome Concrete Soap
57.00
6
Sleek Rubber Shirt
15.75
7
Gorgeous Cotton Computer
80.99
8
Tasty Rubber Shoes
11.89
9
Modern Steel Chair
95.49
10
Licensed Plastic Gloves
9.35
11
Modern Metal Computer
65.00
12
Intelligent Fresh Shirt
26.40
13
Modern Granite Mouse
58.99
14
Luxurious Soft Table
95.00
15
Awesome Metal Sausages
39.50
16
Ergonomic Frozen Gloves
86.00
17
Sleek Soft Soap
37.79
18
Incredible Bronze Gloves
82.50
19
Modern Soft Shirt
27.50
20
Intelligent Metal Fish
75.49
20 rows

You haven't solved this challenge yet!
Are you sure you want to reveal the answer?