oracle - SQL Query - aliasing + different periods + different tables -
i using toad oracle , experienced different issues.
aliasing - when want use same column twice?!
let asume have table x has col1, col2, col3. col1 contains customer contact numbers (211,212,213, , more)
and there table, y, has col1,col4,col5. col1 in both tables equal. col4 shows whether number main or secondary.
table y
(col1,col4,col5) (211,main,v) (212,secondary,s) (213,secondary,w) what want follow :
select col2, col1 mainnumbet, col1 secondnumber x mainnumber in (select col1 y col4 = 'main') , secondnumber in (select col1 y col4 = "secondary") but states there problem !??
there several problems code.
perhaps want:
select x.col2, case when col4 ='main' x.col1 end mainnumber, case when col4 ='secondary' x.col1 end secondnumber, x join y on x.col1 = y.col1
Comments
Post a Comment