Re: SELECT, GROUP BY, and aggregates

From: Igor Neyman <ineyman(at)perceptron(dot)com>
To: Brian Dunavant <brian(at)omniti(dot)com>, Bill Moran <wmoran(at)potentialtech(dot)com>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Ryan Delaney <ryan(dot)delaney(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: SELECT, GROUP BY, and aggregates
Date: 2015-02-13 19:21:55
Message-ID: A76B25F2823E954C9E45E32FA49D70ECC22A1CA0@mail.corp.perceptron.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----Original Message-----
From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Brian Dunavant
Sent: Friday, February 13, 2015 2:11 PM
To: Bill Moran
Cc: Jeff Janes; Ryan Delaney; pgsql-general(at)postgresql(dot)org
Subject: Re: [GENERAL] SELECT, GROUP BY, and aggregates

To lower the amount of time spent copy pasting aggregate column names, it's probably worth noting Postgres will allow you to short cut that with the column position. For example:

select long_column_name_A, long_column_name_b, count(1) from foo group by 1,2 order by 1,2

This works just fine. It's not in the spec, but postgres supports it.
I'll leave it to others to argue about it being a best practice or not.

-----------------------

I use this feature a lot.

Igor Neyman

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Currie 2015-02-13 19:26:13 How can I refer to an ANYELEMENT variable in postgresql dynamic SQL?
Previous Message Brian Dunavant 2015-02-13 19:11:04 Re: SELECT, GROUP BY, and aggregates