|
Posted by Mike C# on 06/14/06 22:29
CREATE TABLE #a (Idx INT NOT NULL PRIMARY KEY,
Val INT NOT NULL)
CREATE TABLE #b (Idx INT NOT NULL PRIMARY KEY,
Val INT NOT NULL)
INSERT INTO #a (Idx, Val)
SELECT 1, 12
UNION SELECT 2, 34
UNION SELECT 3, 45
INSERT INTO #b (Idx, Val)
SELECT 1, 34
UNION SELECT 2, 44
UNION SELECT 3, 98
SELECT a.Idx, a.Val, b.Val
FROM #a a
INNER JOIN #b b
ON a.Idx = b.Idx
ORDER BY a.Idx
DROP TABLE #a
DROP TABLE #b
"vivekian" <vivekaseeja@gmail.com> wrote in message
news:1150320359.977336.291500@i40g2000cwc.googlegroups.com...
> Hi ,
>
> I need to place the results of two different queries in the same result
> table parallel to each other.
> So if the result of the first query is
>
> 1 12
> 2 34
> 3 45
>
> and the second query is
>
> 1 34
> 2 44
> 3 98
>
> the results should be displayed as
>
> 1 12 34
> 2 34 44
> 3 45 98
>
> If a union is done for both the queries , we get the results in rows.
> How can the above be done.
>
> Thanks in advance,
> vivekian
>
Navigation:
[Reply to this message]
|