Subject Re: [ib-support] How put conditions upon a sub-select field?
Author Daniel Rail
At 16/04/2002 11:04 AM, you wrote:
>Hi, I've a query like this (FB 1.0):
>SELECT PIANO_CONTI.ESERCIZIO_ID,
> PIANO_CONTI.CONDOMINIO_ID,
> PIANO_CONTI.CONTO_ID,
> PIANO_CONTI.DESCRIZIONEDISP,
> (SELECT RIPARTITO FROM PIANO_CONTI SSPC WHERE
> (SSPC.ESERCIZIO_ID=OPC.ESERCIZIO_ID) ) RIP
>FROM PIANO_CONTI OPC
>WHERE RIP='S'
>
>and I get the error "Column does not belong to referenced table" referred
>to the "RIP='S'" part.
>How can I refer to that field? It shown as "RIP" if I run the query, but
>adding the Where clause I get that error.

Try:

SELECT PIANO_CONTI.ESERCIZIO_ID,
PIANO_CONTI.CONDOMINIO_ID,
PIANO_CONTI.CONTO_ID,
PIANO_CONTI.DESCRIZIONEDISP,
(SELECT RIPARTITO FROM PIANO_CONTI SSPC WHERE
(SSPC.ESERCIZIO_ID=OPC.ESERCIZIO_ID) ) RIP
FROM PIANO_CONTI OPC
WHERE EXISTS(SELECT * FROM PIANO_CONTI SSPC WHERE
(SSPC.ESERCIZIO_ID=OPC.ESERCIZIO_ID) AND (SSPC.RIPARTITO='S'))



Daniel Rail
Senior System Engineer
ACCRA Group Inc. (www.accra.ca)
ACCRA Med Software Inc. (www.accramed.ca)