Académique Documents
Professionnel Documents
Culture Documents
SELECT DISTINCT
TOP 4 START AT 2
t1.key_1 * 100 AS a,
t3.key_1 * 1000 AS b,
COUNT(*) AS c,
SUM ( t3.non_key_1 ) AS d
INTO #t
FROM ( t1 LEFT OUTER JOIN t2 ON t1.key_1 = t2.key_1 )
CROSS JOIN t3
WHERE b <= 5000
AND t3.non_key_1 = 333
GROUP BY ROLLUP ( t1.key_1, t3.key_1 )
HAVING COUNT(*) > 1
ORDER BY 1, 2
FOR XML AUTO;
This book doesnt go into the details of XML processing. However, here is what
the single column in the single row in the temporary #t looks like, wrapped to fit
the page:
<t1 a="100"><t3 c="2" d="666"/></t1><t1 a="200"><t3 c="6" d="1998"/><t3 b="3000"
c="3" d="999"/><t3 b="4000" c="3" d="999"/></t1>'
For more information about the SELECT INTO method of creating a temporary
table, see Section 1.15.2.3, SELECT INTO #table_name.