Docsity

EJERCICIOS DE BASE DE DATOS 2019, Ejercicios de Programación de Bases de Datos

Vista previa parcial del texto

¡Descarga EJERCICIOS DE BASE DE DATOS 2019 y más Ejercicios en PDF de Programación de Bases de Datos solo en Docsity!

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;