Almacenes y Cajas

an anonymous user · November 25, 2021 · SQL
-- create a table
CREATE TABLE Almacenes
(
Codigo INTEGER NOT NULL PRIMARY KEY,
lugar varchar (40) NOT NULL,
capacidad INTEGER NOT NULL
);
CREATE TABLE Cajas 
(
numreferencia INTEGER NOT NULL PRIMARY KEY,
contenido varchar (100) NOT NULL,
valor INTEGER NOT NULL,
almacen INTEGER NOT NULL
);
insert into Almacenes(codigo, lugar, capacidad) values (34,"Barcelona", 3);
insert into cajas (numreferencia, contenido, valor, almacen) values (987, "papel" 200, 2);
update cajas
set valor=valor -(valor*15/100);
update cajas
set valor=valor -(valor*20/100)
where valor> (select avg(valor) from cajas);
delete
from cajas
where valor <100;
delete
from cajas
where contenido> (select max(contenido) from cajas);

Comments

Please sign up or log in to contribute to the discussion.