I have two columns of x,y coordinates in a table on a Postgres database.
I can find the extremes in x and y using:
select min(x), max(x), min(y), max(y)
from coords
How do assign these to variables something like this:
select min(x) as xmin, max(x) as xmax, min(y) as ymin, max(y) as ymax
from coords
to achieve
select y
from coords
where x = xmin
etc...to obtain the four extreme points in the half-billion row dataset? (the point of the exercise)
the desired select statement works but I can't use the "where" clause as it says that xmin is not a column. What is the correct approach, or in the unlikely event that I am using the correct approach, what is the correct syntax?