Re: SQL problem (forgot to change header with earlier post!). - Mailing list pgsql-general

From Paul Linehan
Subject Re: SQL problem (forgot to change header with earlier post!).
Date
Msg-id CAF4RT5T13GOrq6_YLeXxJwo9GamvSA0U8ZOUW+-vSe8WwTqq5Q@mail.gmail.com
Whole thread Raw
In response to SQL problem (forgot to change header with earlier post!).  (Paul Linehan <linehanp@tcd.ie>)
List 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 by date:

Previous
From: Moreno Andreo
Date:
Subject: Re: SQL problem (forgot to change header with earlier post!).
Next
From: Paul Linehan
Date:
Subject: Re: SQL problem (forgot to change header with earlier post!).