Subject Re: [ib-support] Re: SQL: Number of entries per day
Author Andrew Guts
How about one CAST(ts as date) instead of 3 EXTRACTs there?

Arno Brinkman wrote:

>Hi,
>
>
>
>> I was thinking of returning a date and the number of entries on that
>> 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 a VIEW with EXTRACT and group by the VIEW columns.
>
>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
>
>
>
>
>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/
>
>
>
>