Subject | Re: [ib-support] Re: SQL: Number of entries per day |
---|---|
Author | Arno Brinkman |
Post date | 2002-09-16T12:58:03Z |
Hi,
CREATE VIEW Example1
(TableYear, TableMonth, TableDay) AS
SELECT
EXTRACT(YEAR FROM FieldX),
EXTRACT(MONTH FROM FieldX),
EXTRACT(DAY FROM FieldX)
FROM
ATable;
SELECT
TableYear,
TableMonth,
TableDay
FROM
Example1
GROUP BY
TableYear,
TableMonth,
TableDay
Ofcourse adding your missing fields.
Another way is creating computed by columns with EXTRACT() or UDF's.
Regards,
Arno
> I was thinking of returning a date and the number of entries on thatCreate a VIEW with EXTRACT and group by the VIEW columns.
> day, i.e casting the timestamp using:
>
> CAST(TIME_STAMP as DATE)
>
> I've just tried:
>
> select CAST(ts as date), count(*) as entries
> from run_log
> group by CAST(ts as date)
> having entries > 0
>
> but it complains about the group by entry - 'Unknown toekn CAST'
CREATE VIEW Example1
(TableYear, TableMonth, TableDay) AS
SELECT
EXTRACT(YEAR FROM FieldX),
EXTRACT(MONTH FROM FieldX),
EXTRACT(DAY FROM FieldX)
FROM
ATable;
SELECT
TableYear,
TableMonth,
TableDay
FROM
Example1
GROUP BY
TableYear,
TableMonth,
TableDay
Ofcourse adding your missing fields.
Another way is creating computed by columns with EXTRACT() or UDF's.
Regards,
Arno