Mircea Man - 4 months ago 36

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

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
```