Hi All,
First two column is from one set of query statements and the remaining from other set. I want to display the values in a single row. Can anybody help me
A B C D
NULL NULL 0 22
0 699 NULL NULL
SELECT statement:
SELECT P.A, P.B, T2.C, T2.D
FROM Table1 AS P
JOIN (
SELECT MAX(ID) ID, COUNT(ID) AS A
FROM Table1
WHERE Type = 0
GROUP BY Type) AS A1
ON A1.ParcelID = P.ID
RIGHT OUTER JOIN (
SELECT MAX(ID) ID, COUNT(ID) AS B
FROM Table1
WHERE Type = 1 GROUP BY Type) AS B1
ON B1.ID = P.ID
FULL JOIN (
SELECT R.ID,ISNULL(C1.C,0) C, ISNULL(D1.D,0) D
FROM Table2 AS R
FULL JOIN (
SELECT MAX(ID) ID, COUNT(ID) AS C
FROM Table2
WHERE Type = 0
GROUP BY Type) AS C1
ON C1.ID = R.ID
RIGHT OUTER JOIN (
SELECT MAX(ID) ID, COUNT(ID) AS D
FROM Table2
WHERE Type = 1
GROUP BY Type) AS D1
ON D1.ID = R.ID) AS T2
ON T2.ID = P.ID