Subject Re: [ib-support] How select against a sub-select field?
Author Nando Dessena
Marco,

> 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'
>
> I get the error "Column does not belong to referenced table." about the 'RIP' condition in the where clause.
> Seems that I can not reference that field taht comes from a sub-select. How can I reference it in the Where?

How about a join?

SELECT OPC.ESERCIZIO_ID,
OPC.CONDOMINIO_ID,
OPC.CONTO_ID,
OPC.DESCRIZIONEDISP,
SSPC.RIPARTITO RIP
FROM PIANO_CONTI OPC JOIN PIANO_CONTI SSPC ON
(SSPC.ESERCIZIO_ID=OPC.ESERCIZIO_ID)
WHERE SSPC.RIPARTITO = 'S'

BTW, aliasing a table (PIANO_CONTI OPC) and then referring to its
physical name is a bit confusing, isn't it?
HTH
--
____
_/\/ando