Foros del Web » Programación para mayores de 30 ;) » Bases de Datos General » SQL Server »

Consulta Select

Estas en el tema de Consulta Select en el foro de SQL Server en Foros del Web. Ola! tengo estas tres consultas pero necesito que se conviertan en una sola ... me pueden ayudar?? @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código SQL: Ver original SELECT Llenos ...
  #1 (permalink)  
Antiguo 24/02/2010, 10:44
 
Fecha de Ingreso: febrero-2010
Mensajes: 31
Antigüedad: 14 años, 2 meses
Puntos: 0
Exclamación Consulta Select

Ola! tengo estas tres consultas pero necesito que se conviertan en una sola ... me pueden ayudar??
Código SQL:
Ver original
  1. SELECT Llenos.gran AS ID,Granja.nom_gran AS NOMBRE,Llenos.num_plan AS PLANILLA, Lote.id_lot AS LOTE,Llenos.cil_ent AS 'TOTAL CILINDROS',(SELECT SUM(pes_cil)FROM Llenos) AS 'PESO B.RETIRO',(SELECT SUM(pes_cil)FROM Llenos)
  2. AS 'PESO NO COSUMIDO',Planilla.num_com_plan AS 'O.COMPRA' FROM Llenos,Planilla,Granja,Lote WHERE id_plan=num_plan AND id_gran=gran;
  3.  
  4. SELECT Entrega.gran AS ID,Granja.nom_gran AS NOMBRE,Entrega.num_plan AS PLANILLA,   Lote.id_lot AS LOTE,Entrega.cil_ent AS 'TOTAL CILINDROS',
  5. (SELECT SUM(pes_cil)FROM Entrega) AS 'PESO B.RETIRO',(SELECT SUM(pes_cil)FROM Entrega)  AS 'PESO NO COSUMIDO',Planilla.num_com_plan AS 'O.COMPRA'
  6. FROM Entrega,Planilla,Granja,Lote WHERE id_plan=num_plan AND id_gran=gran;
  7.  
  8. SELECT Vacios.gran AS ID,Granja.nom_gran AS NOMBRE,Vacios.num_plan AS PLANILLA, Lote.id_lot AS LOTE,Vacios.cil_vac AS 'TOTAL CILINDROS',
  9. (SELECT SUM(pes_cil)FROM Vacios) AS 'PESO B.RETIRO',(SELECT SUM(pes_cil)FROM Vacios) AS 'PESO NO COSUMIDO',Planilla.num_com_plan AS 'O.COMPRA'
  10. FROM Vacios,Planilla,Granja,Lote WHERE id_plan=num_plan AND id_gran=gran;
  #2 (permalink)  
Antiguo 24/02/2010, 16:10
Avatar de flaviovich  
Fecha de Ingreso: agosto-2005
Ubicación: Lima, Peru
Mensajes: 2.951
Antigüedad: 18 años, 8 meses
Puntos: 39
Respuesta: Consulta Select

¿Cuál es la relación entre Planilla y Granja?
__________________
No repitamos temas, usemos el Motor de busquedas
Plantea bien tu problema: Ayúdanos a ayudarte.
  #3 (permalink)  
Antiguo 28/02/2010, 22:31
Avatar de R3N0  
Fecha de Ingreso: febrero-2010
Mensajes: 13
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Consulta Select

Supongo q con esto se resuelve tu problema.....sino es asi entonces explica un poco mas y con gusto te ayudamos





SELECT Llenos.gran AS ID,Granja.nom_gran AS NOMBRE,Llenos.num_plan AS PLANILLA, Lote.id_lot AS LOTE,Llenos.cil_ent AS 'TOTAL CILINDROS',(SELECT sum(pes_cil)FROM Llenos) AS 'PESO B.RETIRO',(SELECT sum(pes_cil)FROM Llenos)
AS 'PESO NO COSUMIDO',Planilla.num_com_plan AS 'O.COMPRA' FROM Llenos,Planilla,Granja,Lote WHERE id_plan=num_plan AND id_gran=gran;
union
SELECT Entrega.gran AS ID,Granja.nom_gran AS NOMBRE,Entrega.num_plan AS PLANILLA, Lote.id_lot AS LOTE,Entrega.cil_ent AS 'TOTAL CILINDROS',
(SELECT sum(pes_cil)FROM Entrega) AS 'PESO B.RETIRO',(SELECT sum(pes_cil)FROM Entrega) AS 'PESO NO COSUMIDO',Planilla.num_com_plan AS 'O.COMPRA'
FROM Entrega,Planilla,Granja,Lote WHERE id_plan=num_plan AND id_gran=gran;
union
SELECT Vacios.gran AS ID,Granja.nom_gran AS NOMBRE,Vacios.num_plan AS PLANILLA, Lote.id_lot AS LOTE,Vacios.cil_vac AS 'TOTAL CILINDROS',
(SELECT sum(pes_cil)FROM Vacios) AS 'PESO B.RETIRO',(SELECT sum(pes_cil)FROM Vacios) AS 'PESO NO COSUMIDO',Planilla.num_com_plan AS 'O.COMPRA'
FROM Vacios,Planilla,Granja,Lote WHERE id_plan=num_plan AND id_gran=gran;

Etiquetas: select
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:01.