Using column aliasses in the same query

Поиск
Список
Период
Сортировка
От Robert J.C. Ivens
Тема Using column aliasses in the same query
Дата
Msg-id 647F9FC9-1511-4FBC-A4B9-60AA256A623B@roclasi.com
обсуждение исходный текст
Ответы Re: Using column aliasses in the same query
Re: Using column aliasses in the same query
Список pgsql-general
Hi,

I am not sure if there ever was a feature request for using defined column aliases in the rest of a query.
This would make queries with a lot of logic in those aliased columns a lot smaller and this easier to write/debug.

I already know you can use the following syntax:

SELECT col1, col2, col3, (col2-col3) as col4 FROM (SELECT col1, (long and lots of logic here) as col2, col3 FROM table)
sWHERE col2 < aValue 

But when you need to use (calculated) values from the actual record and or have sub-selects in your main select that
alsoneed to use these values things get really hairy. 
I don't know if the SQL specification allows it but I know that RDBMS's like Sybase already support this.

Any thoughts?


Cheers,
Robert




В списке pgsql-general по дате отправления:

Предыдущее
От: "Henry C."
Дата:
Сообщение: Re: SSDs with Postgresql?
Следующее
От: Radosław Smogura
Дата:
Сообщение: Re: Howto sort the result of UNION (without modifying its type)?