Separating values in one column into separate columns in SQL

时间:2018-02-26 17:54:35

标签: sql sql-server

If I have two columns of data in my table and in the second is a mix of different information, is it possible to separate the data in the second column into separate columns based on information type so that I only have one row per Hotel ID? Eg.

From this:

Hotel ID   Details
1               Paris
1               France
1               EMEA
2               Munich
2               Germany
2               EMEA
3               Christchurch
3               New Zealand
3               APAC

To this:

Hotel ID             City                     Country               Country Region
1                        Paris                     France                     EMEA
2                       Munich                  Germany                  EMEA
3                       Christchurch         New Zealand           APAC

1 个答案:

答案 0 :(得分:2)

From the data you posted there's no way to tell if i.e. EMEA is a City, Country or Country region. You need to have more data in your table like i.e. type column or so indicating what is what.

相关问题