Re: [GENERAL] Confusing order by error

2017-03-31 Thread
> --- t...@sss.pgh.pa.us wrote: > The short answer here is that the SQL committee changed their minds > between SQL92 and later editions of the standard, and PG is attempting > to split the difference and be reasonably compliant with both versions. > ... Thanks Tom! I'll use this as well to make

Re: [GENERAL] Confusing order by error

2017-03-31 Thread
> --- david.g.johns...@gmail.com wrote: > > On Fri, Mar 31, 2017 at 2:45 PM, wrote: > > > I can go with that now that I understand it (and I did not read the docs > > that way), but I guess I was expecting it to see that "upper(name)" isn't > > there, so it should pull that expression apart, find

Re: [GENERAL] Confusing order by error

2017-03-31 Thread Tom Lane
"" writes: > I can go with that now that I understand it (and I did not read the docs that > way), but I guess I was expecting it to see that "upper(name)" isn't there, > so it should pull that expression apart, find "name" and see that in the > output list before it starts searching the input

Re: [GENERAL] Confusing order by error

2017-03-31 Thread David G. Johnston
On Fri, Mar 31, 2017 at 2:45 PM, wrote: > > I can go with that now that I understand it (and I did not read the docs > that way), but I guess I was expecting it to see that "upper(name)" isn't > there, so it should pull that expression apart, find "name" and see that in > the output list before i

Re: [GENERAL] Confusing order by error

2017-03-31 Thread
Thank you Brian and David, I'll use David's reply to refine my question... --- david.g.johns...@gmail.com wrote: > From: "David G. Johnston" > > On Friday, March 31, 2017, wrote: > > > > SELECT t1.pk, t1.name, t1.ref, CONCAT( t2.id , ':', t2.name ) AS > > ref_display > > FROM test_

Re: [GENERAL] Confusing order by error

2017-03-31 Thread David G. Johnston
On Friday, March 31, 2017, wrote: > I'm hoping someone can give us a little help understanding an error in the > ORDER BY clause, because when I read https://www.postgresql.org/ > docs/9.5/static/sql-select.html#SQL-ORDERBY I just don't see anything > that explains the behavior. > > SELECT t1

Re: [GENERAL] Confusing order by error

2017-03-31 Thread Brian Dunavant
From the docs you linked: "Each expression can be the name or ordinal number of an output column (SELECT list item), or it can be an arbitrary expression formed from input-column values." The "name" in your order by is a reference to the output column. The following example shows the same with "

[GENERAL] Confusing order by error

2017-03-31 Thread
I'm hoping someone can give us a little help understanding an error in the ORDER BY clause, because when I read https://www.postgresql.org/docs/9.5/static/sql-select.html#SQL-ORDERBY I just don't see anything that explains the behavior. This is with Pg-9.5.1 on Centos (not that I think the OS m