database - Fetching data from two tables in oracle -
i have 2 result sets :
set 1:
student| count ------ | ------ mohit | 4 rohit | 2 tanvi | 2 jhanvi | 1
set 2:
student| count_star ------ | ------ mohit | 2 rohit | 3 tanvi | 1 arjun | 1 abhay | 3 abhi | 1
expected result set :
student| count | count_star ------ | ------ | ---------- mohit | 4 | 2 rohit | 2 | 3 tanvi | 2 | 1 arjun | na | 1 abhay | na | 3 abhi | na | 1 jhanvi | 1 | na
can me sql query ?
you need union distinct name both table , left join values count count_star
select t.student , table1.count, table2.count_star ( select student table1 union select student table2 ) t left join table1 on table1.student = t.student left join table2 on table1.student = t.student
Comments
Post a Comment