sql - join 2 tables using oracle -


there 2 tables data below. column 'id' available in both tables. can please me how desired output.

table 1:

id  ind   101 y   102 n  

table 2:

id  cd   101   101 b   101 c   101 d   102   

desired output:

id  cd ind   101  y   101 b    101 c    101 d    102  n  

what have here join want display value of ind on first cd of each id. can row_number() window function in case expression:

select t1.id, t2.cd, case rn when 1 t1.ind else null end ind   table1 t1 join   (select id, cd, row_number() on (partition ind order cd asc) rn         table2) t2 on t1.id = t2.id 

Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -