Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux