Advertisement
gmendezm

Entrega reciente de Materiales

May 14th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.05 KB | None | 0 0
  1. -- DROP VIEW EntregaRecienteDeMateriales
  2. CREATE VIEW EntregaRecienteDeMateriales AS
  3. SELECT
  4.     m.nombre AS 'Material',
  5.     materialesConTipo.[Tipo de Material],
  6.     e.cantidad AS 'Cantidad',
  7.     mp.precio AS 'Precio',
  8.     mp.precio * e.cantidad AS 'Total',
  9.     d.nombreDestino AS 'Destino',
  10.     p.nombre AS 'Proyecto',
  11.     e.fechaEntrega AS 'Fecha',
  12.     e.entregaConfirmada AS 'Entrega Confirmada'
  13. FROM
  14. materiales m
  15. INNER JOIN
  16. (
  17. SELECT
  18.     me.idMaterial,
  19.     'Medidor' AS 'Tipo de Material'
  20.     --,codigo
  21. FROM
  22.     medidores me
  23. UNION
  24.     SELECT
  25.         mg.idMaterial,
  26.         cat.nombre AS 'Tipo de Material'
  27.         --,codigo
  28.     FROM
  29.         generales mg
  30.         INNER JOIN
  31.         categorias cat
  32.         ON mg.idCategoria = cat.idCategoria
  33. ) materialesConTipo
  34.  
  35. ON
  36. materialesConTipo.idMaterial = m.idMaterial
  37.  
  38. INNER JOIN
  39.     entregas e
  40.     ON e.idMaterial = m.idMaterial
  41. INNER JOIN
  42.     destinos d
  43.     ON d.idDestino = e.idDestino
  44. INNER JOIN
  45.     proyectos p
  46.     ON p.idProyecto =e.idProyecto
  47. INNER JOIN materiales_proveedores mp
  48.     ON mp.idProveedor = e.idProveedor
  49. GO
  50.  
  51. SELECT * FROM EntregaRecienteDeMateriales
  52. GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement