AYUDA CON SELECT COMPLEJOS

From: "ruben avila galindo" <ruben2218(at)hotmail(dot)com>
To: pgsql-es-ayuda(at)postgresql(dot)org
Subject: AYUDA CON SELECT COMPLEJOS
Date: 2006-08-03 00:17:00
Message-ID: BAY113-F863C3B4ECE36E6334FF6AA8530@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

<html><div style='background-color:'><DIV class=RTE>create table cab_factura<BR>num_fact<BR>tot_fact</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>create table cab_boleta<BR>num_fact<BR>tot_fact</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>create table cliente <BR>cod_per<BR>nom_per</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>Con esta consulta saco los montos totales de cada tabla de cada cliente y lo que quiero unir los dos montos pero no se como hacerlo <BR>y me salen asi la consulta:</DIV>
<DIV class=RTE>JOSE LACHIRA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 165.50&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;-----------&gt;esto es de boleta<BR>JOSE LACHIRA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 50.60&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;------------&gt;esto es de factura<BR>RUBEN AVILA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 150.00<BR>RUBEN AVILA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 300.00</DIV>
<DIV class=RTE>y lo que quieren aca en mi empresa es saber el RANKING DE CLIENTES y la consulta deberia mostrar asi:<BR>JOSE LACHIRA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 216.10<BR>RUBEN AVILA&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 450.00<BR>&nbsp; <BR>espero que me ayuden amigos postgreanos con esta consulta y como podria hacerlo ya que recien empiezo en esta BD<BR>CONSULTA SELECT :</DIV>
<DIV class=RTE>&nbsp;</DIV>
<DIV class=RTE>select p.nom_per,sum(tot_fact) as importe from cab_factura c inner join documentos d on <BR>d.cod_doc=c.cod_doc inner join cliente f on f.cod_cli=d.cod_per inner join persona p on p.cod_per=d.cod_per <BR>where d.cod_per='0200001' group by p.nom_per<BR>union all<BR>select p.nom_per,sum(imp_tot) as importe from cab_boleta g inner join documentos d on <BR>d.cod_doc=g.cod_doc inner join cliente v on v.cod_cli=d.cod_per inner join persona p on p.cod_per=d.cod_per <BR>where d.cod_per='0200001' group by p.nom_per</DIV>
<DIV class=RTE><BR>&nbsp;</DIV></div></html>

Attachment Content-Type Size
unknown_filename text/html 2.5 KB

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Miguel de la Fuente 2006-08-03 00:27:20 Re: AYUDA CON SELECT COMPLEJOS
Previous Message Feri@ 2006-08-03 00:01:54 Consulta