Re: column doesn't exist

From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
To: "Ever Daniel Barreto Rojas" <ebarreto(at)nexusit(dot)com(dot)py>
Cc: pgsql-es-ayuda(at)postgresql(dot)org
Subject: Re: column doesn't exist
Date: 2007-03-15 06:17:10
Message-ID: c2d9e70e0703142317j174f45dx15fab0334e14a694@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

On 3/13/07, Ever Daniel Barreto Rojas <ebarreto(at)nexusit(dot)com(dot)py> wrote:
>
> ERROR: column "articulos" does not exist
> Estado SQL:42703
>
> entiendo que en la parte del WHERE, la variable "articulos" no
> corresponde a ninguna tabla, pero me gustaría saber de qué otra
> forma podría obtener sólamente aquellos registros en donde la
> cantidad de artículos sea mayor a 0
>

la forma simple de resolver tu problema:

SELECT s.idsfamilia,
CAST(f.fam_nombre || ' - ' || s.sfam_nombre
AS character varying(85)) AS familias,
(SELECT COUNT(idarticulo) FROM articulo
WHERE idsfamilia IN (SELECT idsfamilia FROM subfamilia
WHERE idsfamilia = s.idsfamilia)
) AS articulos
FROM familia f INNER JOIN subfamilia s USING(idfamilia)
WHERE (SELECT COUNT(idarticulo) FROM articulo
WHERE idsfamilia IN (SELECT idsfamilia FROM subfamilia
WHERE idsfamilia
= s.idsfamilia)
) > 0
ORDER BY f.fam_nombre, s.sfam_nombre

lo siento, pero tengo mucho sueño para ponerme a pensar en como
reescribir el select en algo mejorcito

--
Atentamente,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jaime Casanova 2007-03-15 06:22:33 Re: column doesn't exist
Previous Message Jaime Casanova 2007-03-15 06:08:09 Re: Hola necesito una opinion fuerte sobre cual es mas rapido m