2016-08-05 83 views
0

我有一個表(表1),如下:SQL讀取網格矩陣

enter image description here

這是一個網格矩陣用於鞋的尺寸。

我想寫一個SQL語句從該表1和顯示閱讀下面

enter image description here

我已用完的想法如何構造SQL這一點。

回答

1
Create table my_new_table as 
    Select grid_code 
    ,'size' attribute_type 
    , 1 attribute_code 
    , size_code_1 attribute_value 
    From my_table 
Union 
Select grid_code 
    ,'size' attribute_type 
    , 2 attribute_code 
    , size_code_2 attribute_value 
    From my_table 
... Etc