Sei sulla pagina 1di 2

---pregunta 1.

select z.descripcion,c.nombre,
sum(dp.cantidad*dp.precunit)as monto
from DETAPEDIDO dp inner join
PEDIDO p on dp.Pedido=p.Pedido
inner join CLIENTE c on p.Cliente=c.Cliente
inner join ZONA z on z.Zona=c.Zona
where DATEPART(yy,p.fecha)>=2003
group by z.Descripcion,c.Nombre
order by 1
---pregunta 2.
select DATEPART(yy,p.fecha)as ao,
DATENAME(mm,fecha)as mes,
count (p.pedido) as cantidad
from PEDIDO p
group by datepart(yy,p.fecha),
datename(mm,p.fecha)
----pregunta 3.
select m.descripcion as marca,sum(dp.cantidad*dp.precunit)as monto
from DETAPEDIDO dp inner join PEDIDO p on dp.Pedido=p.Pedido
inner join CLIENTE c on p.Cliente=c.Cliente
inner join PRODUCTO pr on dp.Producto=pr.Producto
inner join MARCA m on m.Marca=pr.Marca
inner join LINEA l on m.Linea=l.Linea
where l.Descripcion='aceites' and c.Nombre='comer san lorenzo'
group by m.Descripcion
order by 1

----pregunta 4.
select l.descripcion as marcam, sum(dp.cantidad*dp.precunit)as monto
from DETAPEDIDO dp inner join PEDIDO p on dp.Pedido=p.Pedido
inner join PRODUCTO pr on dp.Producto=pr.Producto
inner join MARCA m on m.Marca=pr.Marca
inner join LINEA l on m.linea=l.Linea group by l.Descripcion
order by 1
---pregunta 5.
select datepart(yy,p.fecha)as ao, DATENAME(mm,p.fecha)as mes,
sum(dp.cantidad*dp.precunit)as monto from DETAPEDIDO dp inner join
PEDIDO p on dp.Pedido=p.Pedido
group by DATEPART(yy,p.fecha),DATENAME(mm,p.fecha)
having sum(dp.cantidad*dp.precunit)>1000 order by 1
---pregunta 6.
select pr.descripcion as producto ,DATENAME(mm,p.fecha)mes,

sum(dp.cantidad*dp.precunit)As monto
from DETAPEDIDO dp inner join PEDIDO p on dp.Pedido=p.Pedido
inner join PRODUCTO pr on dp.Producto=pr.Producto
inner join MARCA m on m.marca=pr.marca
inner join linea l on m.Linea=l.Linea where l.Descripcion='leche'
group by pr.Descripcion,DATENAME(mm,p.fecha)
order by 1

Potrebbero piacerti anche