WITH cte AS ( SELECT *, ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) rn FROM (SELECT attribute AS attr1, value AS val1 FROM temp WHERE attribute = 'height') t1 CROSS JOIN (SELECT attribute AS attr2, value AS val2 FROM temp WHERE attribute = 'weight') t2 CROSS JOIN (SELECT attribute AS attr3, value AS val3 FROM temp WHERE attribute = 'gender') t3 ) SELECT rn AS Combination, attr1 AS Attribute, val1 AS Value FROM cte WHERE attr1 = 'height' UNION ALL SELECT rn, attr2, val2 FROM cte WHERE attr2 = 'weight' UNION ALL SELECT rn, attr3, val3 FROM cte WHERE attr3 = 'gender' ORDER BY Combination, Attribute, Value;
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter