SQLTeam.com | Weblogs | Forums

How to display results from 2 queries side by side


#1

I need to display results of 2 queries side by side as follows:
Result of QueryA and Result of QueryB
CodeA CountA CodeB CountB

1 1 1 2
2 3 2 7
3 10 3 4

Thank you


#2

is there any relationship between the left and the right sides?


#3

Hi,
There is no relationship but now I found the solution. This is the example I followed:
SELECT t1.FirstName1, t1.LastName1, t2.FirstName2, t2.LastName2
FROM
(SELECT
FirstName1,
LastName1,
ROW_NUMBER() OVER (ORDER BY FirstName1) 'RowNumber'
FROM table1
) AS t1
FULL OUTER JOIN
(SELECT
FirstName2,
LastName2,
ROW_NUMBER() OVER (ORDER BY FirstName2) 'RowNumber'
FROM table2
) AS t2
ON t1.RowNumber = t2.RowNumber


#4

Sorry. I am looking at this a bit different. Are you wanting to display the results in the same query return? Or, would you like to display the information side by side in SSMS?

When you have two tabs open in ssms. Right click a tab and the below options appear. If this does not help, sorry about that! I thought it was cool though!


#5

I have already resolved this issue, but thanks for asking.


#6

It would be nice to know how you solved or what you did to solve you problem.


#7

What the O/P posted earlier, as a solution, looked interesting to me - I wouldn't have thought to do it that way :slight_smile: