Blue Eye
Blue Eye

Reputation: 49

SQL to read Grid Matrix

I have a table (Table 1) as below:

enter image description here

It is a Grid Matrix for shoe size.

I wanted to write an SQL statement to read from this Table 1 and display as below

enter image description here

I have run out of idea how to construct the SQL for this.

Upvotes: 0

Views: 66

Answers (1)

Strawberry
Strawberry

Reputation: 33945

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

Upvotes: 1

Related Questions