Re: SQL problem (forgot to change header with earlier post!).
От
Moreno Andreo
Тема
Re: SQL problem (forgot to change header with earlier post!).
Дата
Msg-id
8f12a928-d79c-f9f8-197e-4750e203b643@evolu-s.it
Ответ на
SQL problem (forgot to change header with earlier post!). (Paul Linehan)
Список
Дерево обсуждения
SQL problem (forgot to change header with earlier post!). Paul Linehan <linehanp@tcd.ie>
Re: SQL problem (forgot to change header with earlier post!). Moreno Andreo <moreno.andreo@evolu-s.it>
Re: SQL problem (forgot to change header with earlier post!). Paul Linehan <linehanp@tcd.ie>
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.-
В списке pgsql-general по дате отправления
От: Andreas Kretschmer
Дата:
От: Paul Linehan
Дата: