Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, April 30, 2012 9:15 PM
Hey guys
I want to select the most negative value from a column. The column temp that I use variates from -30 °C to +50°C.
When I try this:
SELECT MIN(temp) AS LowestTemp FROM tblMeasures
I get 0 °C. This is "correct" because I have the value 0 °C in my column temp. However, I also have a lower value: -25,8 °C.
It seems that the SELECT MIN() command ignores negative values.
Does anyone know how to solve this?
Thanks in advance.
PS: I don't use SQL server, I only use access 2010. I need to get the value into my C# project. But that's no problem for me, it's just the SQL command that does not give what I desire
All replies (4)
Monday, April 30, 2012 9:32 PM ✅Answered
It should be a decimal or numerical type (if you want to store temperature with decimal points). It should not be character (text). I actually guessed in may be a problem.
For every expert, there is an equal and opposite expert. - Becker's Law
Monday, April 30, 2012 9:21 PM
It works fine for me. What is the type of the temp column?
declare @temperature table (temp decimal(10,2))
insert into @temperature values (-30),(-12.2),(0),(10),(12.5), (31)
select MIN(temp) as [Min Temp], max(temp) as [Max temp]
from @temperature
For every expert, there is an equal and opposite expert. - Becker's Law
Monday, April 30, 2012 9:26 PM
A text type.
I've also been thinking about this, it will probably have to be an int type, right?
That would be a hard job to adjust that in my C# project since I create my tables there.
Monday, April 30, 2012 9:38 PM
Ok i'll try to change the data type of my columns during the debugging of my program.
I'll update this trade as soon as I managed to do so.
Thanks a lot Naomi
EDIT: I changed my column type to "number" and it works now. Thanks Naomi