Search Postgresql Archives

Re: GROUP BY column alias?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 18, 2010, at 4:31 PM, Scott Bailey wrote:
> I'm not sure why you would be surprised by that behavior. You are grouping by a timestamp, so any microsecond difference will be a new group.

I get that. ;)  Hence the ::date.  This is what doesn't make sense:

Expected:     select day::date as bar, count(*) from foo group by bar;
Not Expected: select day::date as day, count(*) from foo group by day;

If I alias it to something other than the actual column name, it does what I expect.  But if I alias it to the column name, it doesn't.

I would have thought that the precedence rules would resolve the alias first, then the column name, but that doesn't seem to be the case.

> If you want to make that work try:
> SELECT day::date, --no need to alias as same name

The "no need to alias as same name" isn't true in my case because the queries I'm dealing with are machine generated, and that's what the generator does, in all cases.

eric
-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux