Subject | Re: [IB-Architect] Aggregate functions request - FIRST() & LAST() |
---|---|
Author | Artur Anjos |
Post date | 2002-02-20T13:24:53Z |
Slavek, I was thinking about something simple to implement, like
MAX(),MIN()...
MS# SQL Jet Engine:
<<
SELECT FIRST(field) AS [expression]
FROM table
[WHERE ...]
[GROUP BY ...]
[ORDER BY ...]
The FIRST function is used to return the value of the first record in the
designated field Therefore, this function returns a single value. Since the
records are returned in an arbitrary order, the first record will also be
arbitrary. You can use the ORDER BY clause to order the records.
The companion LAST function returns the last record in the designated field.
How about trying to keep this request open (I think it's easy to implement,
using the same approach that it's used now for MAX(), MIN(), SUM()....) and
get back to UDAF's in a different request?
Artur
MAX(),MIN()...
MS# SQL Jet Engine:
<<
SELECT FIRST(field) AS [expression]
FROM table
[WHERE ...]
[GROUP BY ...]
[ORDER BY ...]
The FIRST function is used to return the value of the first record in the
designated field Therefore, this function returns a single value. Since the
records are returned in an arbitrary order, the first record will also be
arbitrary. You can use the ORDER BY clause to order the records.
The companion LAST function returns the last record in the designated field.
>>UDAF brings a new world to agg functions...
How about trying to keep this request open (I think it's easy to implement,
using the same approach that it's used now for MAX(), MIN(), SUM()....) and
get back to UDAF's in a different request?
Artur
----- Original Message -----
From: "Slavomir Skopalik" <skopalik@...>
To: <IB-Architect@yahoogroups.com>
Sent: Wednesday, February 20, 2002 8:04 AM
Subject: RE: [IB-Architect] Aggregate functions request - FIRST() & LAST()
> I think about User Definned Agregate Function (UDAF) like UDF.
> I'm of opinion that First() and Last() is too specific.
>
> What do you think about UDAF ?
> My idea is:
> one UDAF will be defined as following set of
> functions (like UDF).
>
> 1. int CreateHandle();
> 2. bool AddElement(int handle, etype element1, etype element2, ... ); /*
succes true else false */
> 3. etype Compute(int handle,etype param1, etype param2);
> 4. void FreeHandle(int handle);
>
> SQL syntax UDAFName(element1,element2,...,param1,param2,...)
>
> where etype can be any basic interbase type (integers, floats, datetimes,
chars,...),
> params for parametrization of Compute function like this:
>
> select MySum(field,2) from table;
> where field is table field and 2 maybe statistical moment or any other
parameter.
>
> If you want eliminate set of functions, this can be realizad by this way:
>
> One function with this interface:
>
> int UDAFName(int command, int handle, *etype element1, *etype element2,
...);
>
> where
> command tell what woudl be do, handle is valid handle or zero.
> command value is like the set of function definition:
> 1=CreateHandle, handle is zero, return is handle or zero
> 2=Add elements, return 1 for true, 0 for false
> 3=Compute result, result is in element1, or return like pointer to
result (after type cast)
> 4=FreeHandle.
>
> For what be used ?
> - statistical computing (median, non normal distribution function
mean,...)
> - Integrations (simpson rule, ...)
> - any special aggregate functions
>
> Slavek