Hello everyone,

I was asked to come up with a solution for a SELECT on multiple columns. I have not seen the database, so I don't know whether it is structurally faulty or could be optimized in one way or another. Anyway, the situation is as follows:
in the first scenario there is a table with multiple columns that hold numeric data. The query ought to return the max value of each mentioned column just like
SELECT MAX(col1), MAX(col2), .... , MAX(coln) FROM table
As there are many (I was told 200) columns this would require to state each column in the MAX(colx) part of the statement.
I would imagine there is a way of retrieving the column names and then looping through the result. Thus saving to state each and every column name. All the solutions I have found or thought of do just that.

And as if that was not enough. Scenario 2 and 3: What if there were also mutliple tables or multiple databases with the same task to find the max values?

Thank you for every suggestion
Have a great day