ClaseAbstracta
Enviado por Esther Bendezu • 29 de Junio de 2023 • Práctica o problema • 1.670 Palabras (7 Páginas) • 36 Visitas
BD VENTAS
SELECT GETDATE()
SELECT YEAR(GETDATE())
SET LANGUAGE SPANISH
SELECT DATENAME(MONTH, GETDATE())
SELECT DATENAME(WEEKDAY, GETDATE())
SELECT DATENAME(WEEKDAY , '30/04/2022')
--1.- Mostrar todos los Clientes cuyo nombre se encuentren entre C y M
SELECT * FROM CLIENTES WHERE CLI_NOM LIKE '[C-M]%'
order by cli_nom
print right('juan perez',4) --erez
print left('juan perez',4) --juan
print substring('juan perez',3,2) --an
print charindex('p','juan perez')
--separar el apellido y nombre
select left(cli_nom,charindex(',',cli_nom)-1) "apellido",
right(cli_nom,len(cli_nom)-charindex(',',cli_nom)) "nombre"
from clientes
--muestre solo los clientes con codigo C0001,C0003,C0007
select *from Clientes where cli_cod='c0001' or
cli_cod='c0003' or cli_cod='c0007'
--operador IN contenido
select *from Clientes where cli_cod in('C0001','C0003','C0007')
--3.- Clientes cuyo apellido empiecen desde D hasta la M
select *from Clientes where cli_nom like '[D-M]%'
order by cli_nom
--4- Mostrar los cinco Clientes con mayor línea de crédito
select top 5 cli_nom, cli_cre from Clientes
order by cli_cre desc;
--los 8 clientes con menor credito
select top 8 cli_nom, cli_cre from Clientes
where cli_cre is not null
order by cli_cre asc;
--funciones fechas
print getdate()
print year(getdate())
print month(getdate())
print day(getdate())
set language spanish
print datename(month,getdate())
print datename(weekday,getdate())
print datename(weekday,'19-12-2001')
--los vendedores con tiempo de servicio de mayor a menor
select ven_nom, year(getdate())-year(ven_fig) "servicio"
from Vendedor order by servicio desc;
--5.-Mostrar todas las ventas del vendedor 2
select * from Fac_cabe where ven_cod=2
--6.- Mostrar que clientes no tienen e-mail
select cli_nom,cli_cor from Clientes where cli_cor is null
--7.- Mostrar las facturas del cliente C0003
select*from Fac_cabe where cli_cod='C0003';
--8.- Mostrar a todos los clientes cuya línea de crédito se encuentre entre 1000 y
--3000 (and or not)
select*from Clientes where cli_cre>=1000 and cli_cre<=3000;
select * from clientes where cli_cre between 1000 and 3000;
...