I have a Numbers table below which contains three numbers (x,y,z):
Numbers table:
+----+----+----+
| x | y | z |
+----+----+----+
| 13 | 15 | 30 |
| 10 | 20 | 15 |
+----+----+----+
I want to produce a new table which contains three more columns:
- min_num: smallest number in the row
- second_min_num: second smallest number in the row
- max_num: largest number in the row
Example output:
+----+----+----+----------+-----------------+----------+
| x | y | z | min_num | second_min_num | max_num |
+----+----+----+----------+-----------------+----------+
| 13 | 15 | 30 | 13 | 15 | 30 |
| 10 | 20 | 15 | 10 | 15 | 20 |
+----+----+----+----------+-----------------+----------+
How can I do this in SQL?