i have in my DB 3 col and i want to find a single value among all of them as explaind here: table name:MyTable
-----------------------------
--id-- col1-- col2-- col3-
-----------------------------
1 200 300 400
2 100 150 300
3 800 102 20
4 80 80 0
i want the result out of col1 col2 col3 to be = 0 , which is the min value among them. is it possible !!!!
my try:
select Min(col1, col2 , col3) as Tablemin
from MyTable
If it is MySQL or Oracle, there is
LEAST()
function:Then, there is the
CASE
statement which can be used in most RDBMSs:This can also work but it's hard to get other fields with the
UNION
approach:In SQLITE the answer is as simple as:
ANSI SQL:
Simple way to display min is: