SQL Server
SQL Server
AGRUPAR TABLAS:
ALTER TABLE Empleado ADD
CONSTRAINT FK_DEPARTAMENTO FOREIGN KEY (numdep) REFERENCES Departamento (numdep)
LISTAR LOS PRODUCTOS CUYO PRECIO DE UNIDAD ESTE ENTRE 45 Y 90 SOLES (nombreProducto,
PrecioUnidad):
select nombreProducto, precioUnidad
from productos Between = entre
where precioUnidad between 45 and 90
LISTAR A LOS CLIENTES QUE NO TIENEN Fax. (nombre compañia, ciudad y país):
select NombreCompañia, ciudad, pais
from clientes
where Fax IS NULL
SELECCIONAR LOS CLIENTES (nombre de compañía, dirección y país), CUYO NOMBRE COMPAÑÍA
EMPIECEN CON LAS LETRAS A, B, C o D, PERTENEZCAN AL país de Alemania Y ORDENARLOS DE MANERA
ASCENDENTE POR EL CAMPO dirección:
SELECT NombreCompañia, Direccion, Pais
FROM Clientes
where NombreCompañia like ('[abcd]%') and Pais='Alemania'
order by Direccion asc
MOSTRAR LA CANTIDAD DE CLIENTE POR PAÍS DONDE DICHA CANTIDAD SEA MAYOR IGUAL 6:
select Pais, count(idCliente) as NroCliente
from clientes
group by pais
having count(idCliente)>=6
SELECCIONAR LOS PEDIDOS QUE SE REALIZARON EN AGOSTO DE CUALQUIER AÑO POR LOS EMPLEADOS
CON CÓDIGO (idempleado) 2 y 5 Y CUYO CÓDIGO DE CLIENTES COMIENCEN CON LAS LETRAS DE LA A
HASTA LA G:
select *
from pedidos
where month(FechaPedido)=08 and IdEmpleado in (2,5) and IdCliente like ('[a-g]%')
LISTAR LOS CAMPOS nombrecategoria y descripción DE LA TABLA Categoria, DE LOS PRODUCTOS CUYO
precioUnidad ESTE ENTRE 45 y 55. TODA ESTA INFORMACIÓN DEBE SER ORDENADA DE MANERA
DESCENDENTE POR EL CAMPO nombrecategoria.
select nombrecategoria,descripcion
from categorias
where idcategoria in (
select idcategoria
from productos
where precioUnidad between 45 and 55
)
order by nombrecategoria desc
MOSTRAR LOS CLIENTES (nombrecompañia, telefono) QUE HAYAN PASADO AL MENOS UN PEDIDO EN EL
AÑO 1996
select NombreCompañia,Telefono
from clientes
where idCliente in (
select idCliente
from Pedidos
where year(FechaPedido)=1996
)
INSERTAR, ELIMINAR Y ACTUALIZAR DATOS
Añadir un nuevo departamento: Número de departamento “G11”, nombre del departamento “GESTION
HUMANA” y numero de dirección “000080”:
insert into Departamento(numdep, nombredep, numdirec)
values ('G11', 'GESTION HUMANA', 000080)
Mostrar los campos “nombreproducto” y la última letra del campo “categoría producto” de la tabla
productos:
select nombreProducto, right(categoriaProducto,1) as categoriaProducto
from productos
JOIN
Mostrar el nombre de los productos y sus unidades en existencia de aquellos productos que
pertenecen a la categoría Bebidas y con unidades en existencia menor a 25:
select nombreProducto, unidadesEnExistencia
from productos A inner join categorias B on A.idcategoria=B.idcategoria
where nombrecategoria='bebidas' and unidadesEnExistencia<25
Mostar el total pagado por cada orden de compras solo del mes de enero del 1996:
PROCEDIMIENTOS ALMACENADOS
Crear un procedimiento almacenado que cuente los productos que empiezan con un determinado
carácter:
Ejemplo: Los productos que empiezan con “T”
CREATE PROCEDURE Cantidad_Producto
@nombre varchar(5)
as
select count(*) as [Cantidad Productos]
from productos
where nombreProducto like @nombre+'%'
---ejecutar
exec Cantidad_Producto 't'
Realizar un procedimiento almacenado que devuelva el precio mayor y el precio menor de según
la categoría:
create procedure Precio_Producto
@NombreCategoria varchar(40)
as
---ejecutar
exec Precio_Producto 'bebidas'
Realizar un procedimiento que permita eliminar el cliente según su
identificación (idcliente). Si el cliente realizo algún pedido mostrar el
siguiente mensaje “No se puede eliminar al cliente” caso contrario se
procede a eliminar al cliente y mostrar el siguiente mensaje “Cliente
eliminado”:
-----EJECUTAR
EXEC ELIMINAR_CLIENTE 'ANATR'
----EJECUTAR
EXEC RANGO_PRECIO 10,50
CARGA MASIVA
https://www.youtube.com/watch?v=3X0nyc5JGl8
Contraseña de manuales de instalación: CEDHINFO
https://drive.google.com/drive/u/1/folders/14jyE6FV6jYluZmBEd7wnUDJ-AAIpLvLW
https://www.youtube.com/watch?v=RajH5hTgL-M
https://www.youtube.com/watch?v=_V5cey9V9dw&t=310s
https://www.youtube.com/watch?v=TmH_794b2I4
https://www.youtube.com/watch?v=3V8mNlKbDAQ
http://cvosoft.com/sistemas_sap_abap/recursos_tecnicos_abap/que-es-sap-pm.php
https://www.youtube.com/watch?v=dVHdyyuLjiA
PLANIFICADO: todo aquello que se identifica mediante una actividad preventiva (ANOMALIAS)
NO PLANIFICADO: Siempre es una falla.
EMERGIACIA: Se sale de los alineamientos de mantenimiento. Ocurre a equipos críticos que
pueden parar la producción