Subject Re: sql error - invalid column reference
Author ronaldorezende
I solve it transforming the 'ANO' in a COMPUTED columns of the table.
Thank you.

The sugest of create a view is not valid for me because I must send
parameters for the query.


--- In ib-support@yahoogroups.com, "Martijn Tonies" <m.tonies@u...> wrote:
>
> Hi,
>
>
> > Is there a way to put the "extract(year from c.DATA_INICIO) Ano" in
> > the group by or in the list of columns?
>
> I don't think you can GROUP BY an EXTRACT expression - give it a
> try. (drop the "ano" stuff)
>
> You can workaround this by doing:
>
> GROUP BY ABS(EXTRACT(year FROM c.DATA_INICIO))
>
> After declaring the ABS UDF in your database.
>
> Check the docs on how to do that.
>
> With regards,
>
> Martijn Tonies
> Database Workbench - the developer tool for InterBase & Firebird
> Upscene Productions
> http://www.upscene.com
>
> See you at the First European Firebird Conference in May in Fulda,
Germany
> http://www.firebird-conference.com
>
> >
> >
> > --- In ib-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@u...> wrote:
> > >
> > > When using a GROUP BY, or SUM or other aggregate
> > > function, you need to use one on each column.
> > >
> > > Both of these columns are not mentioned in the GROUP BY
> > > clause.
> > >
> > >
> > > > Hi, I receive this error when I put this two fields in sql.
> > > > d.DESCRICAO_DISCIPLINA_PADRAO,
> > > > extract(year from c.DATA_INICIO) Ano
> > > >
> > > >
> > > > select
> > > > da.ID_CURSO,
> > > > da.ID_DISCIPLINA,
> > > > da.ID_ALUNO,
> > > > sum(da.NOTA_DIARIO) Nota,
> > > > sum(da.QTD_FALTA_DIARIO) Faltas,
> > > > d.DESCRICAO_DISCIPLINA_PADRAO,
> > > > extract(year from c.DATA_INICIO) Ano
> > > > from DIARIO_ALUNO da
> > > > left join DISCIPLINA d on d.ID_DISCIPLINA = da.ID_DISCIPLINA
> > > > left join CURSO c on c.ID_CURSO = da.ID_CURSO
> > > > where da.ID_ALUNO = :id_aluno and da.ID_CURSO = :id_curso
> > > > group by da.ID_CURSO, da.ID_DISCIPLINA, da.ID_ALUNO
> > >
> > >
> > > With regards,
> > >
> > > Martijn Tonies
> > > Database Workbench - the developer tool for InterBase & Firebird
> > > Upscene Productions
> > > http://www.upscene.com
> > >
> > > See you at the First European Firebird Conference in May in Fulda,
> > Germany
> > > http://www.firebird-conference.com
> >
> >
> >
> > To unsubscribe from this group, send an email to:
> > ib-support-unsubscribe@egroups.com
> >
> >
> >
> > Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
> >
> >
> >