join - SQL table joining different people -


i join 2 tables showing different information population in table zp there people not shown in wg. add these people zp final table, in columns there no information, have zeros.

select *  mobility.mzmv2010.wegeinland wg join mobility.mzmv2010.zielpersonen zp using ("hhnr","zielpnr")  

an example can seen in picture:

image

presumably, want left join . . . person table first:

select coalesce(sum(zp."wp" * "w_rdist")/(62868 * avg(zp."wp")), 0) mobility.mzmv2010.zielpersonen zp left join      mobility.mzmv2010.wegeinland wg      using ("hhnr", "zielpnr") ; 

note: should qualify w_rdist column specify table coming from.


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 -