• No se han encontrado resultados

Consulta - select * from cliente whe Página número 1

N/A
N/A
Protected

Academic year: 2021

Share "Consulta - select * from cliente whe Página número 1"

Copied!
5
0
0

Texto completo

(1)

---- Facturas a clientes de antequera

select fa.* from Factura fa inner join Cliente cl on fa.cClnNif=cl.cClnNif where cClnPbl='pueblo1';

---- Facturas a clientes que nos han comprado más de 50 euros

select cClnNif, sum(nFctArtUnd*nArtPrc) from Factura f inner join FctArt fa on f.nFctN mr=fa.nFctNmr

group by cClnNif

having sum(nFctArtUnd*nArtPrc) > 50;

select * from Factura where cClnNif in (select cClnNif from Factura f inner join FctArt fa on f.nFctNmr=fa.nFctNmr

group by cClnNif

having sum(nFctArtUnd*nArtPrc) > 50); ---- articulos vendidos al cliente 'nfi1'

select distinct cArtFml, cArtCdg from Factura f inner join FctArt fa on f.nFctNmr=fa.nFctNmr

where cClnNif='nif1';

---- articulos vendidos en las facturas del cliente 'nif1' ---es el mismo que el de arriba

---- facturas que no tienen el articulo 'f1' 'a1' calculo de las facturas que tienen f1 a1

select nFctNmr from FctArt where cArtFml='f1' and cArtCdg='a1'; solucion

select * from factura where nFctNmr

not in (select nFctNmr from FctArt where cArtFml='f1' and cArtCdg='a1'); ---- clientes sin facturas

calculo de los clientes que tienen facturas select distinct cClnNif from factura; select *from cliente where cClnNif

not in (select distinct cClnNif from factura); solucion con left outer join

(2)

---- Articulos que no se han vendido

select distinct cArtFml, cArtCdg from FctArt;

select * from Articulo where (cArtFml + cArtCdg) not in (select distinct cArtFml + cArtCdg from FctArt);

---- Limpiadores que no se han estrenado

select cLmpNif from limpiador where cLmpNif not in (select distinct cLmpNif from lavado);

---- Limpiadores que han limpiado vehiculos que ha limpiado en limpiador 'lnif1' select cVhcMtr from lavado where cLmpNif = 'lnif1';

select distinct cLmpNif from lavado where cVhcMtr in

(select distinct cVhcMtr from lavado where cLmpNif = 'lnif1');

---- Vehiculos que se han lavado más veces que el vehiculo con matriculo m1 --vehiculo y numero de lavado de cada vehiculo

select cVhcMtr, count(*) from lavado group by cVhcMtr

having count(*) > (select count(*) from lavado where cVhcMtr = 'm1');

--- prueba de la función case sobre la tabla notas create table notas (

cAlmNmb char(30),

nNotNmr decimal (2,0) check (nNotNmr between 0 and 10) ); insert into notas values ('cebrian', 4);

insert into notas values ('humanes', 5); insert into notas values ('tirado', 6); insert into notas values ('campaña',1); select * from notas;

(3)

select cAlmNmb, case nNotNmr when 0 then 'Muy deficiente' when 1 then 'Muy deficiente'

when 2 then 'Muy deficiente' when 3 then 'Insuficiente' when 4 then 'Insuficiente' when 5 then 'Suficiente' when 6 then 'Suficiente' when 7 then 'Bien'

when 8 then 'Notable' when 9 then 'Sobresaliene' when 10 then 'Matricula' else 'Error en los datos' end nota_texto

from notas;

--- ejemplo de case para los mese del año create table fecha (

miFecha datetime);

insert into fecha values ('1-1-2008'); insert into fecha values ('1-4-2008'); insert into fecha values ('1-7-2008'); insert into fecha values ('1-10-2008');

select case month(miFecha) when 1 then 'enero' when 2 then 'febrero' when 3 then 'marzo' when 4 then 'abril' when 5 then 'mayo' when 6 then 'junio' when 7 then 'julio' when 8 then 'agosto' when 9 then 'septiembre' when 10 then 'octubre' when 11 then 'noviembre' when 12 then 'diciembre' end mes

(4)

--- formato de la sentencia CASE con condiciones sobre notas: select cAlmNmb, case when nNotNmr < 3 then 'Muy deficiente'

when nNotNmr < 5 then 'Insuficiente' when nNotNmr < 7 then 'Suficiente' when nNotNmr < 8 then 'Bien'

when nNotNmr < 9 then 'Notable'

when nNotNmr < 10 then 'Sobresaliene' when nNotNmr = 10 then 'Matricula' else 'Error en los datos'

end nota_texto from notas;

--- el formato anterio condicional es valido para campos decimales create table notas2 (

cAlmNmb char(30),

nNotNmr decimal (4,2) check (nNotNmr between 0 and 10)); insert into notas2 values ('asfdawere', 3.5);

insert into notas2 values ('asfdads', 2.5); insert into notas2 values ('asfdads', 5.5); insert into notas2 values ('asfdaf', 7.5);

select cAlmNmb, case when nNotNmr < 3 then 'Muy deficiente' when nNotNmr < 5 then 'Insuficiente'

when nNotNmr < 7 then 'Suficiente' when nNotNmr < 8 then 'Bien'

when nNotNmr < 9 then 'Notable'

when nNotNmr < 10 then 'Sobresaliene' when nNotNmr = 10 then 'Matricula' else 'Error en los datos'

end nota_texto from notas2;

(5)

insert into cliente values ('nif1a', 'kkkk', 'calle2', 'Vva Trabuco', '44'); insert into cliente values ('nif2a', 'kkkk', 'calle2', 'Vva Rosario', '44'); insert into cliente values ('nif1b', 'kkkk', 'calle2', 'Vva Algaidas', '44'); insert into cliente values ('nif2b', 'kkkk', 'calle2', 'La Roda', '44');

--- clientes de pueblos de nueva implantación select * from cliente where cClnPbl like 'Vva%'; --- cliente cuyo telefono no empieza por 44

select * from cliente where cClnTlf not like '44%'; --- cliente cuyo telefono no empieza por 1

select * from cliente where cClnTlf not like '1%'; --- clientes cuyo telefono empieza por 1

select * from cliente where cClnTlf not like '1%'; ---- cliente cuyo nombre not tiene k

select * from cliente where cClnNmb not like '%k%'; --- clientes cuyo pueblo acaba en 1

select * from cliente where cClnPbl like '%1'; --- clientes cuya tercera letra del nif sea f

select * from cliente where cClnNif like '__f%';

---- Listado de los clientes que tienen más de tres facturas ---- Listado de los clientes que sólo nos han comprado una vez

---- Numero de lavados y numero de vehiculos diferentes que ha lavado cada limpiador ---- Vehiculos cuyos lavados se han factura en facturas del cliente 'nif1'

---- vehiculos cuya matricula es de Malaga formato antiguo

---- Vehiculos cuya matricula es andaluza según formato antiguo ? ---- Vehiculos que se han lavado más de 8 veces.

Referencias

Documento similar

Todos los datos que usa o genera se acogen a los estándares internacionales que rigen este tipo de sistemas, tanto para la compresión de imágenes, como para

“Extracción de los caracteres de la matrícula” (Fig 1.2) recibe como entrada una imagen digital, que representa la matrícula, y retorna un conjunto de imágenes digitales (cada

Modelo de Aplicación: Diseñado para mejorar el desarrollo, el mantenimiento y el soporte, proporciona un modelo de tres niveles para diseñar y desarrollar aplicaciones

Encargado de coordinar y gerenciar el area de logistica, manejo de indicadores, supervicion de despachos, entregas y vehiculos, compras e inventarios, realizar inventarios

5.2 Los métodos de ensayo para verificar los requisitos de los vehículos denominados microbus de transporte público de pasajeros intrarregional, interprovincial e

COMPONENTE 1 2 Services 173 1 HN-04-Compra_Menor 11 20,833 HNL 2 UAP/PMSB HN-0801 15101505; UAP-UAP/PMSB ADQUISICION DE COMBUSTIBLE DIESEL PARA VEHICULOS DE LA UGP DEL PROYECTO

A medida que aumentamos el ángulo de ataque, el flujo tiene más dificultades para seguir la curvatura del perfil y la separación de la capa límite se produce antes,

El tercero tiene notas bajas pero la mayor es estadística, una de las temáticas trabajadas de forma más mecánica, asimismo el último arquetipo muestra que, aun con notas buenas,