I have a simple table with site_names and site_area sizes. Now I want to now which sites are larger than the site called 'bullepolder' in Postgres. The site_area is 14 ha. So I can use:
SELECT site_name, site_area
FROM site
WHERE site_area >= '14'
But it is kind of a hastle to look up al the sizes before I can query and if the area size changes the query isn't suitable anymore. Is there an easier way? Can site_name be linked to site_area somehow?
Use a sub-select.
select site_name, site_are
from site
where site_area > (select s2.site_area
from site s2
where s2.site_name = 'bulledpolder');
The above assumes that site_name
is unique. If it's not, you will get an error.