Reputation:
I'm using MySQL, and I'm looking for a way to get the global maximum and minimum values (for the whole table) from two columns (for example, posx
and posy
), using only one query.
Upvotes: 7
Views: 16967
Reputation: 58962
SELECT
MIN(colx) AS minimum,
MAX(colx) AS maximum,
MIN(coly) AS minimum,
MAX(coly) AS maximum
FROM table
Upvotes: 4
Reputation: 124297
It's really no more complex than it sounds.
SELECT MIN(posx), MAX(posx), MIN(posy), MAX(posy)
FROM yourtable
Upvotes: 4
Reputation: 67147
Simple:
SELECT MIN(posx), MIN(posy), MAX(posx), MAX(posy) FROM table
Upvotes: 18