I have a query:
select *
from randomtable
where randomnumber <> 0
The column “random_number” will never be a negative number.
So, if I write the query as:
select *
from randomtable
where randomnumber > 0
Is there any major difference?
No, there is no difference at all (in your specific situation). All numeric comparisons take the same time.
What’s done at the lowest level is that zero is subtracted from randomnumber, and then the result is examined. The > operator looks for a positive non-zero result while the <> operator looks for a non-zero result. Those comparisons are trivial, and take the same amount of time to perform.