Query question

Поиск
Список
Период
Сортировка
От Sharma, Sid
Тема Query question
Дата
Msg-id ACFDE9C6BE48D9498A073197F80ED98C06B31A29@EXVIP3.bjw2k.asg
обсуждение исходный текст
Ответы Re: Query question  ("Adam Rich" <adam.r@sbcglobal.net>)
Список pgsql-general

Hi,

 

I am new to Postgres and am trying to write a query like the one below (without any luck)

 

SELECT col_speed, col_time, (col_speed / col_time) AS distance

FROM speed_ratings

HAVING distance > ?

ORDER BY distance

 

In other words, I want to filter on a calculated column. But I get an error that column distance is not defined

column "distance" does not exist at character 272

 

Interestingly if I remove the filter (HAVING distance > ?), the query works. So I can sort on distance but not filter.

I have tried substituting the HAVING clause with a WHERE clause as well with no luck.

I have also added a GROUP BY clause with the HAVING as well with no luck.

 

Any ideas?

Thanks

Sid

 

 

 

 

 

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

Предыдущее
От: Simon Riggs
Дата:
Сообщение: Re: Warm standby failover mechanism
Следующее
От: "Adam Rich"
Дата:
Сообщение: Re: Query question