SELECT occurance1.id as id, occurance1.value1 from source_table occurance1
union all
SELECT occurance2.id as id, occurance2.value2 from source_table occurance2
union all
SELECT occurance3.id as id, occurance3.value3 from source_table occurance3
union all
...
SELECT occurance20.id as id, occurance20.value20 from source_table occurance20`
2条答案
按热度按时间mbskvtky1#
你可以用
UNPIVOT
a条款SELECT
这样地:结果集如下所示:
从中看到它http://sqlfiddle.com/#!4/bf9cb/8/0型
jckbn6z72#
您可以这样创建sql-