Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- DROP VIEW EntregaRecienteDeMateriales
- CREATE VIEW EntregaRecienteDeMateriales AS
- SELECT
- m.nombre AS 'Material',
- materialesConTipo.[Tipo de Material],
- e.cantidad AS 'Cantidad',
- mp.precio AS 'Precio',
- mp.precio * e.cantidad AS 'Total',
- d.nombreDestino AS 'Destino',
- p.nombre AS 'Proyecto',
- e.fechaEntrega AS 'Fecha',
- e.entregaConfirmada AS 'Entrega Confirmada'
- FROM
- materiales m
- INNER JOIN
- (
- SELECT
- me.idMaterial,
- 'Medidor' AS 'Tipo de Material'
- --,codigo
- FROM
- medidores me
- UNION
- SELECT
- mg.idMaterial,
- cat.nombre AS 'Tipo de Material'
- --,codigo
- FROM
- generales mg
- INNER JOIN
- categorias cat
- ON mg.idCategoria = cat.idCategoria
- ) materialesConTipo
- ON
- materialesConTipo.idMaterial = m.idMaterial
- INNER JOIN
- entregas e
- ON e.idMaterial = m.idMaterial
- INNER JOIN
- destinos d
- ON d.idDestino = e.idDestino
- INNER JOIN
- proyectos p
- ON p.idProyecto =e.idProyecto
- INNER JOIN materiales_proveedores mp
- ON mp.idProveedor = e.idProveedor
- GO
- SELECT * FROM EntregaRecienteDeMateriales
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement