This must be one of repetiting questions in many forums.
Solutions are:
1) Self join, if maximum number of rows to be combined was fixed.
2) XMLAGG.
3) Recursive query.
Here is an answer(variation of Andy's):
Code:
------------------------------ Commands Entered ------------------------------
WITH
/* Sample Data */
table_a(Name, Keyword, Value) AS (VALUES
('Ted', 'City', 'New York')
,('Ted', 'Job', 'Doctor')
,('Ted', 'Hobby', 'Biking')
) /* End of Sample Data */
SELECT a1.name || ' ' || a1.value || ' ' || a2.value || ' ' || a3.value
AS "Combined result"
FROM table_a a1
LEFT JOIN
table_a a2
ON a2.name = a1.name
AND a2.keyword = 'Job'
LEFT JOIN
table_a a3
ON a3.name = a1.name
AND a3.keyword = 'Hobby'
WHERE a1.keyword = 'City'
;
------------------------------------------------------------------------------
Combined result
------------------------------
Ted New York Doctor Biking
1 record(s) selected.