Subject Re: [firebird-support] Re: Group by date on a timestamp field
Author Martijn Tonies
> >>Thanks Adam! Works great. Why can't I use something like:
> >>
> >>select cast(myfieldname as Date) as SomeName, count(*)
> >>from mytablename
> >>group by SomeName
> >
> > Because expressions in SELECT are calculated after expressions in
> > GROUP BY.
>
> Then why does this work ??
> select cast(myfieldname as Date), count(*)
> from mytablename
> group by 1

because Firebird no longer follows the SQL standard in this case :-)

The SQL standard says that a "group by" can only be done on base
table (or view) columns, not derived columns in the resultset.

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com