これは私がこれまでに持っているものですが、あまりにも多くの結果を示しています。説明行をうまくグループ化していますが、結果ごとにそれを行っています。私は基本的にそれが欲しいので、3行しかありません。クラスごとに 1 つhttp://prntscr.com/1la4j2
/* 3. List the part number, part description, and item class for each pair of parts that are in the same item
class */
SELECT
t1.partnum,
STUFF((
SELECT ', ' + t2.description
FROM part t2
WHERE t1.class = t2.class
FOR XML PATH (''))
,1,2,'') AS description, t1.class
FROM part t1