| From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
|---|---|
| To: | Yessica Brinkmann <yessica(dot)brinkmann(at)gmail(dot)com> |
| Cc: | Raul Andres Duque <raulandresduque(at)hotmail(dot)com>, pgsql-es-ayuda(at)postgresql(dot)org |
| Subject: | Re: Obtengo un error al tratar de sumar dos sum |
| Date: | 2006-12-26 19:07:01 |
| Message-ID: | 20061226190701.GG28727@alvh.no-ip.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
Yessica Brinkmann escribió:
> Buenas tardes.
> Yo pensaba que había solucionado el problema usando la siguiente sentencia:
> select SUM(subtable.Valor) as total
> FROM
> (
> SELECT sum(TBL_VENTAS.monto) AS valor
> FROM TBL_VENTAS
> WHERE TBL_VENTAS.Id_Empresa = 247
> UNION
> SELECT sum(TBL_EXPORTACIONES.monto) AS Valor
> FROM TBL_EXPORTACIONES
> WHERE TBL_EXPORTACIONES.Id_Empresa = 247
> ) subtable
> pero me di cuenta ahora recién que estoy obteniendo solamente el valor
> del segundo select del UNION, y no el total general.
> Agradeceré cualquier comentario al respecto.
Usa UNION ALL.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Yessica Brinkmann | 2006-12-26 19:12:28 | Re: Obtengo un error al tratar de sumar dos sum |
| Previous Message | Mario | 2006-12-26 18:38:37 | Re: UNSUSCRIBE |