Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-23 Thread Rafal Pietrak
On Sat, 2012-09-22 at 20:00 -0700, Chris Travers wrote: > On Sat, Sep 22, 2012 at 12:23 AM, Jasen Betts > wrote: > On 2012-09-18, Rafal Pietrak wrote: [-] > > could be written by user as (3): > > SELECT 1/x AS inverse FROM data WHERE x <> 0 AND >

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-22 Thread Chris Travers
On Sat, Sep 22, 2012 at 12:23 AM, Jasen Betts wrote: > On 2012-09-18, Rafal Pietrak wrote: > > > > Actual Tom's example(1): > > SELECT 1/x AS inverse FROM data WHERE x <> 0; > > extended to (2): > > SELECT 1/x AS inverse FROM data WHERE x <> 0 AND 1/x > 20; > > could be written by us

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-22 Thread Jasen Betts
On 2012-09-18, Rafal Pietrak wrote: > > Actual Tom's example(1): > SELECT 1/x AS inverse FROM data WHERE x <> 0; > extended to (2): > SELECT 1/x AS inverse FROM data WHERE x <> 0 AND 1/x > 20; > could be written by user as (3): > SELECT 1/x AS inverse FROM data WHERE x <> 0 AND i

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-20 Thread David Johnston
> > On Wed, Sep 19, 2012 at 11:15 PM, David Johnston > wrote: > > I could maybe see something like the following having some value: > > > > SELECT inverse > > FROM data > > WHERE x<>0 AND inverse > .5 > > MACRO inverse (1/x) > > > > WITH macros AS (SELECT *,1/x AS inverse FROM data) SELECT inver

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-19 Thread Chris Angelico
On Wed, Sep 19, 2012 at 11:15 PM, David Johnston wrote: > I could maybe see something like the following having some value: > > SELECT inverse > FROM data > WHERE x<>0 AND inverse > .5 > MACRO inverse (1/x) > WITH macros AS (SELECT *,1/x AS inverse FROM data) SELECT inverse FROM macros WHERE x<>0

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-19 Thread David Johnston
> -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Behalf Of Steve Haresnape > Sent: Wednesday, September 19, 2012 2:37 AM > To: pgsql-general@postgresql.org > Subject: Re: [GENERAL] RFE: Column aliases in WHE

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-19 Thread Rafal Pietrak
On Wed, 2012-09-19 at 20:36 +0800, Craig Ringer wrote: > On 09/19/2012 02:36 PM, Steve Haresnape wrote: > > > Since some dialects support the idiom and others don't there can't be > > any compelling reason to withhold support. It's really a matter of style. > > For my money the DRY style is better

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-19 Thread Craig Ringer
On 09/19/2012 02:36 PM, Steve Haresnape wrote: Since some dialects support the idiom and others don't there can't be any compelling reason to withhold support. It's really a matter of style. For my money the DRY style is better. So you're saying that you want the implementation to effectively

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-18 Thread Steve Haresnape
Hi There, I've snipped a piece for the daily digest because I take issue with what's asserted here as a reason for not allowing aliases in where clauses. << snipThis isn't just academic nit-picking either, because the SELECT expressions might not be valid for rows that don't pass WHERE etc.

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-18 Thread Chris Angelico
On Tue, Sep 18, 2012 at 4:44 PM, Craig Ringer wrote: > On 09/18/2012 07:32 AM, Tom Lane wrote: >> >> It's easier to understand why this is if you realize that SQL has a very >> clear model of a "pipeline" of query execution. > > I just wish they hadn't written it backwards! > > It'd be much less c

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-18 Thread Rafal Pietrak
On Mon, 2012-09-17 at 16:44 -0700, Mike Christensen wrote: > On Mon, Sep 17, 2012 at 4:32 PM, Tom Lane wrote: > > Mike Christensen writes: [---] > > It's easier to understand why this is if you realize that SQL has a very > > clear model of a "pipeline" of query execution. Conceptually

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-17 Thread Craig Ringer
On 09/18/2012 07:32 AM, Tom Lane wrote: It's easier to understand why this is if you realize that SQL has a very clear model of a "pipeline" of query execution. I just wish they hadn't written it backwards! It'd be much less confusing were it formulated as something like: SELECT FROM thetable

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-17 Thread Mike Christensen
On Mon, Sep 17, 2012 at 4:32 PM, Tom Lane wrote: > Mike Christensen writes: >> This definitely makes sense in the context of aggregation, but I'm >> wondering if the same argument applies in the use case originally >> posted: > >> SELECT left(value, 1) as first_letter >> FROM some_table >> WHERE

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-17 Thread Tom Lane
Mike Christensen writes: > This definitely makes sense in the context of aggregation, but I'm > wondering if the same argument applies in the use case originally > posted: > SELECT left(value, 1) as first_letter > FROM some_table > WHERE first_letter > 'a'; > Obviously, you can write this as: >

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-17 Thread Mike Christensen
On Mon, Sep 17, 2012 at 3:10 PM, Daniel Serodio (lists) wrote: > Ryan Kelly wrote: > > On Mon, Sep 17, 2012 at 06:18:53PM -0300, Daniel Serodio (lists) wrote: > > It would be nice if PostgreSQL supported column aliases in WHERE > clauses, eg: > > SELECT left(value, 1) AS first_letter > FROM some_t

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-17 Thread Daniel Serodio (lists)
Ryan Kelly wrote: On Mon, Sep 17, 2012 at 06:18:53PM -0300, Daniel Serodio (lists) wrote: It would be nice if PostgreSQL supported column aliases in WHERE clauses, eg: SELECT left(value, 1) AS first_letter FROM some_table WHERE first_letter> 'a'; Is this the proper mailing list for such featu

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-17 Thread David Johnston
On Sep 17, 2012, at 17:42, Ryan Kelly wrote: > On Mon, Sep 17, 2012 at 06:18:53PM -0300, Daniel Serodio (lists) wrote: >> It would be nice if PostgreSQL supported column aliases in WHERE >> clauses, eg: >> >> SELECT left(value, 1) AS first_letter >> FROM some_table >> WHERE first_letter > 'a'; >

Re: [GENERAL] RFE: Column aliases in WHERE clauses

2012-09-17 Thread Ryan Kelly
On Mon, Sep 17, 2012 at 06:18:53PM -0300, Daniel Serodio (lists) wrote: > It would be nice if PostgreSQL supported column aliases in WHERE > clauses, eg: > > SELECT left(value, 1) AS first_letter > FROM some_table > WHERE first_letter > 'a'; > > Is this the proper mailing list for such feature re

[GENERAL] RFE: Column aliases in WHERE clauses

2012-09-17 Thread Daniel Serodio (lists)
It would be nice if PostgreSQL supported column aliases in WHERE clauses, eg: SELECT left(value, 1) AS first_letter FROM some_table WHERE first_letter > 'a'; Is this the proper mailing list for such feature requests? Thanks in advance, Daniel Serodio -- Sent via pgsql-general mailing list (p