mysql - SQL Join issue with two tables -


select tablea.z, count(tablea.z), count(tableb.y) tablea join tableb on tablea.y = tableb.y group tablea.z; 

i'm trying count(tableb.y)/count(tablea.z).

each 1 works fine when find them individually when join tables shown above, count(tablea.z) turns count(tableb.y).

any tips?

you need able evaluate 2 table counts independently of each other:

i may have trying count wrong, hope helps give idea on going on

select     a.z, a.numrows / b.numrows calc -- perhaps error checking avoid /0 error (select z, count(*) numrows tablea group z)     join   (select z, count(*) numrows tableb group z) b      on a.z = b.z 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -