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 excercise, I think you don't need them
> DDL and DML (simplified) at the bottom of post.
>
>
> I tried various combinations of things like basic SELECTs.
>
>
> SELECT avg FROM ((SELECT cnt1 FROM v1)/(SELECT cnt2 FROM v2));
Maybe I didn't catch the problem, but
select (select count(*) from t1) / (select count(*) from t2)::float
should be a starting point (if you need an integer as a return value,
simply remove the ::float at the end
HTH
Moreno.-