Add Two Different Queries Result Into One Table
I have two different query (having same no. of columns in result). I want to put both in one table. for example i have following table: id country salary 1 us
Solution 1:
If your DBMS support window functions, you may use them to join your intermediate result appropriately.
select t1.id, t1.country, t1.salary, t2.id, t2.country, t2.salary
from
(
select*, row_number() over (orderby id) rn
from data
where country ='us'
) t1
fulljoin
(
select*, row_number() over (orderby id) rn
from data
where country ='uk'
) t2 on t1.rn = t2.rn
RESULT
id country salary id country salary
-------------------------------------------1 us 100002 uk 250003 us 350004 uk 31000nullnullnull5 uk 26000
Post a Comment for "Add Two Different Queries Result Into One Table"