Id name xh
Zhang SAN 1
Li si 2
3 fifty 3
.
Hope can use SQL take into a record, each staff was quite a field, not in a field,
The select... The from...
Tom, dick and harry fifty
CodePudding user response:
select case when id=1 then the name end,
Case the when id=2 then name the end,
Case the when id=3 then name the end
From the table.
CodePudding user response:
Can not write id or serial number, for example there are 5 records, written statement of die?CodePudding user response:
PIVOT in the query clause and UNPIVOT clausesCodePudding user response:
Oracle 11 after, there was a pivot methodAs
with t(select 1 id, 'zhang' name from dual
Union all
Select id, 2 'bill' name from dual
Union all
Select 3, 'Cathy' from dual
Union all
Select 4, 'zhao four from dual)
Select * from (select id, name from t) pivot (Max (name) for id in (1, 2, 3, 4))
CodePudding user response: