Está en la página 1de 2

PRACTICA TIENDA DE INFORMATICA

FABRICANTES
Código
Nombre

ARTICULOS
Código
Nombre
precio
Fabricante

1.-OBTENER EL NOMBRE DE LOS ARTICULOS DE LA TIENDA


select nombre from articulos;
2.-OBTENER LOS NOMBRES Y LOS PRECIOS DE LOS ARTICULOS DE LA TIENDA
select nombre,precio from articulos;
3.-OBTENER EL NOMBRE Y PRECIO DE LOS ARTICULOS CUYO PRECIO SE MENOR O IGUAL A 200
select nombre,precio from articulos where precio <= 200;
4.-OBTENER TODOS LOS DATOS DE LOS ARTICULOS CUYO PRECIO ESTA ENTRE LOS 60 Y LOS 120
/* CON AND */
select *from articulos where precio>=60 and precio<=120;

/* CON BETWEEN*/
select *from articulos where precio between 60 and 120;
5.-OBTENER EL NOMBRE Y EL PRECIO EN DOLARES (ES DECIR, EL PRECIO EN DOLARES
MULTIPLICADO x 16
/*sin AS */
select nombre,precio * 16 from articulos;

/*con AS */
select nombre,precio * 16 as Precio_En_Dolares from articulos;
6.-SELECCIONAR EL PRECIO MEDIO DE TODOS LOS ARTICULOS
select avg(precio) from articulos;
7.-OBTENER EL PRECIO MEDIO DE LOS ARTICULOS CUYO CODIGO DEL FABRICANTE SEA 2
select avg(precio) from articulos where fabricante=2;
8.-OBTENER EL NUMERO DE ARTICULOS CUYO PRECIO SEA MAYOR O IGUAL A 180
select count(*) from articulos where precio>=180;
9.-OBTENER EL NOMBRE Y EL PRECIO DE LOS ARTICULOS CUYO PRECIO SEA MAYOR O AGUAL A
180 Y ORDENARLOS DESCENDENTEMENTE POR PRECIO Y LUEGO ASCENDENTEMENTE POR
NOMBRE
select nombre,precio from articulos where precio>=180 order by precio desc, nombre;
select nombre,precio from articulos where precio>=180 order by nombre asc, precio;
10.-OBTENER UN LISTADO COMPLETO DE LOS ARTICULOS INCLUYENDO POR CADA ARTICULO,
LOS DATOS DEL ARTICULO Y DE SU FABRICANTE
/*sin inner join*/
select *from articulos,fabricantes where articulos.codigo=fabricantes.codigo;

/*con inner join*/


select *from articulos inner join fabricantes on articulos.codigo=fabricantes.codigo;
11.-OBTENER UN LISTADO DE ARTICULOS INCLUYENDO EL NOMBRE DEL ARTICULO, SU PRECIO Y
EL NOMBRE DE SU FABRICANTE
select articulos.nombre,precio,fabricantes.nombre from articulos inner join fabricantes on
articulos.codigo=fabricantes.codigo;

12.-OBTENER EL NOMBRE Y PRECIO DEL ARTICULO MAS BARATO


select nombre,precio from articulos where precio = (select min(precio) from articulos);

13.-OBTENER EL NOMBRE Y PRECIO DEL ARTICULO MAS CARO


select nombre,precio from articulos where precio = (select max(precio) from articulos);

14.-AGREGAR UN CAMPO EN LA TABLA FABRICANTES CON EL NOMBRE DE CODIGO_POSTAL


alter table fabricantes add codigo_postal integer not null;

15.-LLENAR LOS DATOS DEL CAMPO CODIGO_POSTAL


update fabricantes set codigo_postal=50100 where codigo=100;

16.-BORRAR EL REGISTRO HP DE LA TABLA FABRICANTES


delete from fabricantes where nombre="hp";

17.-ELIMINAR EL CAMPO LLAMADO CODIGO_POSTAL


alter table fabricantes drop column codigo_postal;

18.-APLICAR UN DESCUENTO DEL 15% A TODOS LOS ARTICULOS

update articulos set precio = precio * 0.15;

También podría gustarte