Subject Re: [ib-support] Extract Function
Author Helen Borrie
At 07:38 PM 14-11-02 +0530, you wrote:
>hi
> I am using an extract function with Group By Clause.But the Results
> are very different. For example my Query is
>
>Select Count(ID), Extract (Day from Msg_Date)
> >From DR_Main
>Group By Msg_Date ( I tried using Group By (Day From Msg_Date) but
>if failed so i tried using Only Msg_Date)
Ajay,
You cannot yet group by an internal function expression; but you can group
by a UDF expression. The FreeUDFLib has this function:

declare external function f_DayOfMonth
date
returns
integer by value
entry_point 'DayOfMonth' module_name 'FreeUDFLib;

So, if you install this library (which you can pick up from www.cvalde.com)
you can do this in FirebirdSQL:

Select Count(ID), Extract (Day from Msg_Date)
From DR_Main
Group By DayOfMonth(Msg_Date)

The following would form groups but would not give the same (or even
similar) results:

Select Count(ID), Msg_Date, Extract (Day from Msg_Date)
From DR_Main
Group By Msg_Date

heLen