I have an sql table and I want to select the min value excluding 0. Any idea how can I do so?
CodePudding user response:
You can execute the following request
SELECT min(field)
FROM table
WHERE field != 0
CodePudding user response:
The query you've provided (shown below) is not going to work since you are using aggregate function (min) in the where clause, which is not allowed.
declare @min int = (select min(note) from dbo.notation **where min(note) != 0)**; print cast(@min as varchar);
I think Maxime Challon's query will give you the expected result.