简体   繁体   中英

combine multiple rows in excel document having only one column value different to single row showing different values as different column

i have an excel sheet in which my data table contains data as shown below

   name       job     salary
   sumit    carpenter  1000
   sumit    teacher    1000
   sumit    doctor     1000

table is as shown above i want to represent data like this

name       job1    job2      job3     salary
sumit    carp..  teacher   doctor   1000

is there any function to do this i want to convert this data to sql or is there any sql query that can perform the above specified task

If you are using Oracle database then you can you PIVOT clause to active this kind of record. let's consider your table name is EMP .

SELECT *
FROM
  ( SELECT * FROM EMP
  ) PIVOT (MAX (JOB) FOR JOB IN ('carpenter' AS "JOB1",'teacher' AS "JOB2",'doctor' AS "JOB3"));

Demo

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM