How to merge the output of two SELECT statements in Oracle Oracle?


I have two Select queries.

The first Select query gives the output which has two columns viz.

A   B
1   2
3   4
5   6
7   8

The second Select query given the output which as two columns viz Column B and Column C. All the values in Column B of this select statement matches the values of Column B of the first Select statement.i.e

B   C
2   25
4   50
6   30
8   50

Now, I need to merge the outputs of the above two Select queries. i.e

A   B   C
1   2   25
3   4   50
5   6   30
7   8   50

I cannot use views to store the output of the two select queries. I need to use the Column B in both select queries to merge. However, I am not able to figure out how to go about it.

If you have elaborated queries (not just tables to join), you may try using with construction

    Query1 as ( -- <- Put your 1st Query text here
      select A,
    Query2 as ( -- <- Put your 2nd Query text here
      select B,

 select Query1.A,
   from Query1,
  where Query1.B = Query2.B

If your case is not that complicated, e.g. both Query1 and Query2 are in fact tables, say Table1 and Table2 you can do well with a simpler solution:

 select Table1.A,
   from Table1,
  where Table1.B = table2.B