I have a table like this:
A B C D E F G H
------------------------------
8 7 8 10 6 5 7 10
9 9 9 10 8 7 9 9
10 9 8 6 6 9 6 6
10 9 8 7 7 7 9 8
And I need a query that returns the maximum and minimum of each column, like this:
A B C D E F G H
------------------------------
8 7 8 6 6 5 6 6
10 9 9 10 8 9 9 10
I'm pretty new on SQL, and I'm stuck here.
I think, this query should help you:
select MIN(A), MIN (B), MIN (C), MIN (D), MIN (E), MIN (F), MIN (G), MIN (H)
from yourTable
union all
select MAX(A), MAX (B), MAX (C), MAX (D), MAX (E), MAX (F), MAX (G), MAX (H)
from yourTable
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.