sql - ms access combining rows -
sql - ms access combining rows -
this seems should simple solution reason cannot wrap head around this.
i have table has user_full_name
primary key , 15 columns of various metrics right. have instances multiple user_full_name
's spelled incorrectly should in fact summed same row. ie. "david hands" spelt "davide handes" , "bobby orr" spelt "boby or." there 150 rows total in table there 136 unique user_full_name
.
how can write sql query merge 150 rows unique 136 rows user_full_name
should combined in fact combined??
i have added column matrix table called tps_user_names
, 1 user_full_name
, 1 duplicate_user_full_name
. query i've come not seem work:
select tun.user_full_name, sum(ad.processed_mss) all_data advertisement left bring together tps_user_names tun on ad.user_full_name = tun.user_full_name , ad.user_full_name = tun.duplicate_user_full_name ad.user_full_name = 'a' , ad.user_full_name = 'a1' grouping tun.user_full_name
not strictly coding solution, create matrix table has 2 columns, duplicated user_full_names , actual user_full_name, left bring together table , utilize actual user_full_name whenever aggregations. short of revisiting schema or correcting errors in table itself, best way, imo. in case keeps happening, add together row matrix table instead of changing code. (it should noted can utilize interim step involving matrix table re-normalize original table. key relationship issues aside, can create matrix, pull aggregated query, utilize reinsert into/update original table.)
edit: have supplied code, here modifications can create integrate new table mix:
select nz(tun.user_full_name, ad.user_full_name) user_full_name_agg, sum(ad.processed_mss) all_data advertisement left bring together tps_user_names tun on ad.user_full_name = tun.duplicate_user_full_name grouping nz(tun.user_full_name, ad.user_full_name);
the nz select first non-null value tun.user_full_name or ad.user_full_name finds. dupes, utilize consolidated user_full_name finds in tun, others, 1 in ad.
sql ms-access sum
Comments
Post a Comment