Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Your code
- create table fg_180512_interactors_matches_party distkey(matched_id) sortkey(matched_id) as
- select
- democrats.fg_180512_interactors_matches_2.matched_id, -- Use an alias, a in this instance.
- source_id,
- score,
- LEFT(b.vb_vf_voter_status,1) as vb_vf_voter_status,
- LEFT(b.vb_vf_party,1) as vb_vf_party,
- ROUND(b.ts_tsmart_partisan_score) as ts_tsmart_partisan_score
- from democrats.fg_180512_interactors_matches_2 a
- left join ts.ntl_current as b using (matched_id) -- Matched id doesn't exist in ts.ntl_current, so you can't join on this column.
- -- See below for example of a.key = b.key
- -- Working code...
- create table fg_180512_interactors_matches_party distkey(matched_id) sortkey(matched_id) as
- select
- matched_id, --removed schema designation
- source_id,
- score,
- LEFT(b.vb_vf_voter_status,1) as vb_vf_voter_status,
- LEFT(b.vb_vf_party,1) as vb_vf_party,
- ROUND(b.ts_tsmart_partisan_score) as ts_tsmart_partisan_score
- from democrats.fg_180512_interactors_matches_2 as a -- Added an alias, use this instead of a full table/schema name.
- left join ts.ntl_current as b on a.matched_id=b.vb_voterbase_id
- -- Aliases, here is a basic example.
- select
- a.primary_key -- You are grabbing the column from table1
- b.first_name -- You aer grabbing the column from table2
- from schema.table1 as a
- left join schema.table2 b on a.primary_key = b.primary_key
Add Comment
Please, Sign In to add comment