

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!


select nroboleta, (select fecha from tboleta where tboleta.nroboleta=tdetalle.nroboleta) fecha, cantidad, preciounitario, cantidad*preciounitario from Tdetalle where nroboleta in (select nroboleta from TBoleta where month(fecha)= 8 and year(fecha)= 2008 ) and codproducto='P002'
select row_number() over(order by nroboleta) as 'No', nroboleta, (select fecha from tboleta where tboleta.nroboleta=tdetalle.nroboleta) fecha, cantidad, preciounitario, cantidad*preciounitario from Tdetalle where nroboleta in (select nroboleta from TBoleta where month(fecha)= 8 and year(fecha)= 2008 ) and codproducto='P002'
SELECT tboleta.codcliente, SUM(Tdetalle.cantidad) total FROM tboleta INNER JOIN tdetalle ON tdetalle.nroboleta = tboleta.nroboleta AND month(tboleta.fecha)= 8 and year(tboleta.fecha)= 2008 GROUP BY tboleta.codcliente ORDER BY total DESC
select codproducto, cantidadpreciounitario from Tdetalle where nroboleta in (select nroboleta from TBoleta where month(fecha)= 8 and year(fecha)= 2008 ) ORDER BY cantidadpreciounitario DESC
select codproducto from tproducto where codproducto not in (select codproducto from tdetalle)
CREATE FUNCTION [dbo].[fn_boletas] (@precio int) returns @boletas table-- nombre de la tabla --formato de la tabla (nroboleta varchar( 6 ), nombres varchar( 100 ), fecha datetime, montototal decimal( 6 , 2 ), cantprodven real ) as begin insert @boletas select nroboleta, (select nombres+' '+apellidos from tcliente where codcliente=(select codcliente from tboleta where nroboleta=b.nroboleta)), (select fecha from tboleta where nroboleta=b.nroboleta),cantidad*preciounitario,cantidad from tdetalle b where preciounitario > @precio return end;