I have a table with the following structure:
+——+————–+————–+
| SHOP | BUY_PROFIT | SELL_PROFIT |
+——+————–+————–+
| A | 10 | 15 |
+——+————–+————–+
I need to write select statement to make it look like this:
+——+——+——–+
| SHOP | TYPE | PROFIT |
+——+——+——–+
| A | BUY | 10 |
| A | SELL | 15 |
+——+——+——–+
2
Answers
Some SQL looks like this may work:
You can create the desired output by using a union of two selections:
You can take this a step further and order this by shop and test for null values if desired: