how to transform vertical fields in a table to horizontal result by SQL
问题 I have a table like this: create table t1 { person_id int, item_name varchar(30), item_value varchar(100) }; Suppose person_id+item_name is the composite key, now I have some data (5 records) in table t1 as below: person_id ====item_name ====== item_value 1 'NAME' 'john' 1 'GENDER' 'M' 1 'DOB' '1970/02/01' 1 'M_PHONE' '1234567890' 1 'ADDRESS' 'Some Addresses unknown' Now I want to use SQL (or combing store procedure/function or whatever) to query the above result (1 result set) become: NAME=