Tuesday, December 12, 2017

Q: Achieving the row level least value along with its column name

You asked: I need to have  a query which will give me the smallest value in a table and the column containing it. Please note there can be any number of columns. All will be number data type.

We said: This can be achieved by unpivoting the result set and then group them to find their minimum value as shown below.