Re: where cannot use alias name of column?
От | Giorgio Volpe |
---|---|
Тема | Re: where cannot use alias name of column? |
Дата | |
Msg-id | 3BA1D860.867DB5A4@gtngroup.it обсуждение исходный текст |
Ответ на | Re: where cannot use alias name of column? (Peter Eisentraut <peter_e@gmx.net>) |
Список | pgsql-general |
Peter Eisentraut wrote: > Giorgio Volpe writes: > > > May be it's my ignorance about sql ... > > but why cannot i use alias name of a column in a where clause? > > > > # select key as cc from mytable where cc > 0; > > ERROR: Attribute 'cc' not found > > If you want to use an alias in the WHERE clause you have to > introduce it in the FROM clause, such as: > > SELECT * FROM mytable AS myalias (xx, yy, zz) WHERE zz > 0; > > This may or may not be actually useful in your case. > ok & thanks ... actually in my case does not help i would like to rename a value from an expression so to use it in the where clause without rewriting the expression! ... for example! select date_part('month',my_date) as month from my_table where month = 3; it would be very nice with very complex expressions! (also avoiding postgresql to evaluate them twice or more times!) is there a workaround for this? -- Giorgio -----------------------------------------
В списке pgsql-general по дате отправления: