Re: SQL problem (forgot to change header with earlier post!).

Поиск
Список
Период
Сортировка
От Paul Linehan
Тема Re: SQL problem (forgot to change header with earlier post!).
Дата
Msg-id CAF4RT5T13GOrq6_YLeXxJwo9GamvSA0U8ZOUW+-vSe8WwTqq5Q@mail.gmail.com
обсуждение исходный текст
Ответ на SQL problem (forgot to change header with earlier post!).  (Paul Linehan <linehanp@tcd.ie>)
Список pgsql-general
Hi, and thanks for taking the trouble to reply!


> WITH num AS
> (
>   SELECT count (*) as cnt1 FROM v1
> ),
> div AS
> (
>   SELECT count (*) as cnt2 FROM v2
> )
> SELECT (num.cnt1::numeric/div.cnt2);

I get this error

ERROR:  missing FROM-clause entry for table "num"
LINE 9: SELECT (num.cnt1::numeric/div.cnt2);

Check out the fiddle here -
https://dbfiddle.uk/?rdbms=postgres_10&fiddle=9fbe33f971b12ce637d03c1e7e452831


> Casting as numeric just in case you might have integer division...


Yeah, forgot about the CASTing bit for the other method!

Thanks again!


Pól...


> Todd


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

Предыдущее
От: Moreno Andreo
Дата:
Сообщение: Re: SQL problem (forgot to change header with earlier post!).
Следующее
От: Paul Linehan
Дата:
Сообщение: Re: SQL problem (forgot to change header with earlier post!).