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

Consultas SELECT

Estas en el tema de Consultas SELECT en el foro de Bases de Datos General en Foros del Web. Estas son las consultas que hiice y Kiiero uniirlas es un solo "select"... @import url("http://static.forosdelweb.com/clientscript/vbulletin_css/geshi.css"); Código SQL: Ver original SELECT Llenos . gran AS ID ...
  #1 (permalink)  
Antiguo 19/02/2010, 14:26
 
Fecha de Ingreso: febrero-2010
Mensajes: 31
Antigüedad: 14 años, 2 meses
Puntos: 0
Consultas SELECT

Estas son las consultas que hiice y Kiiero uniirlas es un solo "select"...

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',
  2. (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'
  3. FROM Llenos,Planilla,Granja,Lote
  4. WHERE id_plan=num_plan AND id_gran=gran;
  5.  
  6.  
  7. 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',
  8. (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'
  9. FROM Entrega,Planilla,Granja,Lote
  10. WHERE id_plan=num_plan AND id_gran=gran;
  11.  
  12. 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',
  13. (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'
  14. FROM Vacios,Planilla,Granja,Lote
  15. WHERE id_plan=num_plan AND id_gran=gran;

Última edición por tatis003; 19/02/2010 a las 15:06
  #2 (permalink)  
Antiguo 19/02/2010, 14:32
Avatar de huesos52
Colaborador
 
Fecha de Ingreso: febrero-2009
Ubicación: Manizales - Colombia
Mensajes: 5.980
Antigüedad: 15 años, 3 meses
Puntos: 360
Respuesta: Consultas SELECT

Con tan pocos detalles te recomiendo el operador UNION.

saludos
__________________
Without data, You are another person with an opinion.
W. Edwads Deming
  #3 (permalink)  
Antiguo 19/02/2010, 14:42
 
Fecha de Ingreso: febrero-2010
Mensajes: 31
Antigüedad: 14 años, 2 meses
Puntos: 0
Respuesta: Consultas SELECT

Miira estas son las consultas que hiice y pos kiiero uniirlas...


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;


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;

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 05:21.