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

From: Paul Linehan <linehanp(at)tcd(dot)ie>
To: Todd Sykes <toddsykes(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: SQL problem (forgot to change header with earlier post!).
Date: 2018-05-29 11:51:45
Message-ID: CAF4RT5T13GOrq6_YLeXxJwo9GamvSA0U8ZOUW+-vSe8WwTqq5Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul Linehan 2018-05-29 11:57:02 Re: SQL problem (forgot to change header with earlier post!).
Previous Message Moreno Andreo 2018-05-29 11:39:53 Re: SQL problem (forgot to change header with earlier post!).