答案 0 :(得分:0)
您可以使用row_number()
并进行条件聚合:
SELECT individuaid,
MAX(CASE WHEN seq = 1 THEN item_no END) item_no_1,
MAX(CASE WHEN seq = 1 THEN HL2_CODE END) HL_2_1,
. . . .
FROM (SELECT t.*,
ROW_NUMBER() OVER (PARTITION BY individuaid ORDER BY item_no) AS seq
FROM table t
) T
GROUP BY individuaid;