I have a table, I want to get all the max values of col1, col2, col3 using one query only. I’m using sqlite and flask-sqlalchemy.
| id | col1 |col2 |col3 | -------- | -------------- |-------------- |--------------| | 1 | 1 | 88 |26 | | 2 | 2 | 17 |30 | | 3 | 5 | 9 |75 | | 4 | 93 | 2 |53 |
I tried
SELECT MAX(col1, col2, col3) FROM table
but then I got [(88,), (30,), (75,), (93,)]
I want the output to be
[(93,), (88,), (75,)]
How can I do this?
Advertisement
Answer
I think you want three separate calls to MAX
here:
SELECT MAX(col1), MAX(col2), MAX(col3) FROM yourTable;