I've got a table which contains a column named size.
I want with a min function to find the min value of size and a set of integer.
For example : Size can be : 5, 10, 15 And I want to find the min result in a set like : MIN(size,1)
Min method does not seem to have several parameters...
I've tried something like:
SELECT min(1, size) FROM myTable
SELECT min(SELECT 1,size FROM myTable) FROM myTable
There is error for each of these syntax. I precise that I 开发者_C百科can't do the comparison in my code because the sql is generated and can be something more complex like:
SELECT min(SELECT size FROM table1, SELECT size FROM table2, 10)
FROM table3
Any idea ?
You can use least
to find the minimum across columns/expressions and min
to find the minimum across rows.
SELECT min(least(1, size)) FROM myTable
Or this would probably be more efficient actually
SELECT least(1,min(size)) FROM myTable
精彩评论