R
R
Roman Kuzmenko2016-01-27 22:21:54
MySQL
Roman Kuzmenko, 2016-01-27 22:21:54

How to make a selection in MySQL (minimum value)?

Hello! Can you please tell me how to correctly organize the selection of the minimum value from the table?
The conditions are as follows:
The table contains price values ​​0,0,0,0,150,300,2560 You
must select the minimum value that is not equal to 0, and if everything is 0, then 0 accordingly.
I would be grateful for your help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
riot26, 2016-01-27
@devrvk

Try like this:

SELECT MIN(NULLIF(`price`, 0))
FROM `mytable`;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question