Re: confusing `case when` column name

2024-03-12 Thread Daniel Gustafsson
> On 12 Mar 2024, at 15:19, Tom Lane wrote: > users are probably going to end up applying an AS clause most of > the time if they care about the column name at all. If anything, we could perhaps add a short note in the CASE documentation about column naming, the way it's phrased now a new user c

Re: confusing `case when` column name

2024-03-12 Thread Tom Lane
"David G. Johnston" writes: > On Tuesday, March 12, 2024, adjk...@126.com wrote: >> Nee we change the title of the case-when output column? > Choosing either a or b as the label seems wrong and probably worth changing > to something that has no meaning and encourages the application of a column

Re: confusing `case when` column name

2024-03-12 Thread David G. Johnston
On Tuesday, March 12, 2024, adjk...@126.com wrote: > > Nee we change the title of the case-when output column? > > Choosing either a or b as the label seems wrong and probably worth changing to something that has no meaning and encourages the application of a column alias. David J.

confusing `case when` column name

2024-03-12 Thread adjk...@126.com
Hi hackers, Below is a `case when` demo, ```sql create table foo(a int, b int); insert into foo values (1, 2); select case 1 when 1 then a else b end from foo; ``` Currently, psql output is, ```text b --- 1 (1 row) ``` At the first glance at the output column title, I assume the result of