can you help me with this sql exercise?

0

Increase the price by 10% of products whose value is less than 100,000

create table producto(
  cod_producto int primary key,
  desc_producto varchar(20),
  precio_producto int
);

insert into producto values (100,'Televisor Led',198000);

insert into producto values (200,'Refrigerador',127500);

insert into producto values (300,'Cocina',84000);

insert into producto values (400,'Juguera',18000);

- I know it's done with an "update" but I do not know how I can increase the value by 10%

    
asked by Patricio 16.11.2017 в 00:01
source

1 answer

0

the query would be more like this:

update producto set precio_producto = precio_producto + (precio_producto*0.1) where precio_producto < 100000

What I do is update the price_product field with its same value + the calculation of the 10% that would be (product_price * 0.1) or ((10 * price_product) / 100) either is valid, with the condition that the price before to change it is less than 100000.

Oh and you must change the data type of the product price to decimal (18.2) because with the sum you may obtain decimals. I hope it has served you if it is what you were looking for

Greetings.

    
answered by 16.11.2017 в 00:36