Re: select function alias
От | btober@computer.org |
---|---|
Тема | Re: select function alias |
Дата | |
Msg-id | 464073177.95002308.1480518926815.JavaMail.zimbra@broadstripe.net обсуждение исходный текст |
Ответ на | Re: select function alias (Howard News <howardnews@selestial.com>) |
Ответы |
Re: select function alias
|
Список | pgsql-general |
From: "Howard News" <howardnews@selestial.com>
Sent: Wednesday, November 30, 2016 9:03:28 AM
Subject: Re: [GENERAL] select function aliasOn 30/11/2016 13:42, Timoteo Blanco wrote:I've a series of timestamp columns I'd like to alias in select statements. psql indicates my alias doesnt exist after3 options:I define it.Example -> select to_char(impressions_create_date,'yyyy-mm-dd') as ymd from impressionsdb where ymd like '2016-11%' ;psql always complains column ymd does not exist. I've inherited a series of tables with many timestamps and would like toshorten the select in queries without renaming any columns.
- Use the same to_char expression in the where clause
- Use a sub-select to use the alias in the outer where clause
- Use the original column in the where clause and use the timestamp comparisson functions.
4. Define views on the tables. Make the views writeable using rules.
5. Use a CTE:
with shortnames as (
select to_char(impressions_create_date,'yyyy-mm-dd') as ymd from impressionsdb
) select ymd from shortnames where ymd like '2016-11%';
-- B
В списке pgsql-general по дате отправления: