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

2018-05-29 Thread Adrian Klaver
On 05/29/2018 06:52 AM, Adrian Klaver wrote: On 05/29/2018 05:05 AM, Paul Linehan wrote: Hi again, and thanks for your efforts on my behalf! WITH num AS (     SELECT count (*) as cnt1 FROM v1   ), div AS (     SELECT count (*) as cnt2 FROM v2   )   SELECT (num.cnt1::numeric/div.cnt2)  From num

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

2018-05-29 Thread Adrian Klaver
On 05/29/2018 05:05 AM, Paul Linehan wrote: Hi again, and thanks for your efforts on my behalf! WITH num AS ( SELECT count (*) as cnt1 FROM v1 ), div AS ( SELECT count (*) as cnt2 FROM v2 ) SELECT (num.cnt1::numeric/div.cnt2) From num cross join div; I've tried running this co

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

2018-05-29 Thread Paul Linehan
Hi again, and thanks for your efforts on my behalf! > WITH num AS > ( >SELECT count (*) as cnt1 FROM v1 > ), > div AS > ( >SELECT count (*) as cnt2 FROM v2 > ) > SELECT (num.cnt1::numeric/div.cnt2) > From num cross join div; I've tried running this code 4 different ways and none of th

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

2018-05-29 Thread Paul Linehan
Hi and grazie for your reply! > If it's not an excercise, I think you don't need them Not an exercise - I have to use the VIEW though - this was only a sample. In real life the VIEW is trickier! > select (select count(*) from t1) / (select count(*) from t2)::float Looks as if the CAST was pa

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

2018-05-29 Thread Paul Linehan
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::n

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

2018-05-29 Thread Moreno Andreo
Il 29/05/2018 13:14, Paul Linehan ha scritto: Hi all, I have a problem that I just can't seem to solve: I want to divide the count of one table by the count of another - seems simple enough! I created simple VIEWs with counts of the tables, but I just can't grasp the logic! If it's not an exce