I'm currently trying to select from a table of locations. The result should be the closest location and additionally a location that is at least 30km distance away.

So i'm trying to do a 

```
SELECT * FROM locations WHERE (distance = minimumdistance OR distance > 30) AND some other parameters LIMIT 2

```

But i can't get the min distance without a second select that has all the other parameters too which will make the statement massively long.

MIN(distance) needs a grouping but that would result in me getting only one result instead of 2...

Is there any way to do this more simple? Create the statement without having the full WHERE clause two times within the statement.

Currently it's

```
SELECT * FROM locations WHERE (distance = (SELECT MIN(distance) FROM locations WHERE some other parameters ) OR distance > 30) AND some other parameters LIMIT 2

```

now try to imagine that with some other parameters beeing a pretty long string and distance beeing a calculation instead of a static table column and this becomes pretty nasty.