teradata - SQL - A table with two same column names -
i have table user_id , entitlement entitlement can full game or demo, given user_id have 2 rows if user played both full game , demo.
i did join table 2 columns gives me info on whether or not user has played full game has played demo. first column gives me ids of players has played full game, while second column repeat id if player has played demo, or null if he/she hasn't.
select * ( (select e.user_id table1 e entitlement = 'fullgame') fg left join (select e.user_id table1 e entitlement = 'demo') demo on fg.user_id = demo.user_id )
my problem when i'm trying join table tables other information (age, country), teradata sql assistant gives me error saying there 2 columns of same name, i.e. user_id
how can write query distinguish between 2 columns. have somehow rename 1 of columns first?
you can use alias so:
select * ( (select e.user_id userid1 table1 e entitlement = 'fullgame') fg left join (select e.user_id userid2 table1 e entitlement = 'demo') demo on fg.userid1 = demo.userid2 )
you can use as
keyword if or can write e.user_id userid1
, both mean same thing.
Comments
Post a Comment