Mircea Man - 10 months ago 75

SQL Question

How can i select the minimum of two variables in hsql query language?

I need something like

`"select ... as x ... as y.... where min(x,y) <= value"`

The

`min()`

`max()`

Thanks in advance.

Answer Source

You probably mean the LEAST value:

```
SELECT LEAST(x , y) FROM MYTABLE
SELECT X, Y FROM MYTABLE WHERE LEAST(X,Y) <= value
SELECT X, Y FROM MYTABLE WHERE X <= value OR Y <= value /* this is more efficient */
```

You can select the minimum value among the LEAST values of the two variables in a row:

```
SELECT MIN(LEAST(x , y)) FROM MYTABLE
```