Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 wrong value with MAX and MIN

Author  Topic 

aoyarce
Starting Member

2 Posts

Posted - 2009-04-09 : 16:07:34
i have the next statement:

SELECT MAX(temperatura) AS Expr1
FROM Tabla1


but instead of get the maximun value,
i got another value.
for example if my column temperatura have the values 1,2,3,4,5
and i make the query, instead of get 5, i get 2 and i dont know why.

the most extrange is that in the same Tabla1, y have another ten columns, but when i make the same query, i got the right value.

can anybody tell me what is wrong with me SQL?

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2009-04-09 : 16:28:16
what is the datatype of the column temparatura?

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

dsindo
Starting Member

45 Posts

Posted - 2009-04-10 : 15:14:34
not much to look at.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-04-10 : 15:24:17
quote:
Originally posted by dsindo

not much to look at.



Very informative!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

aoyarce
Starting Member

2 Posts

Posted - 2009-04-13 : 16:06:19
the datatype is a nchar(10)
but the value that i insert its a float,
may be a problem when the number is like 1.123e4?

now i add another table with float number,
but do the same thing...
Go to Top of Page

dsindo
Starting Member

45 Posts

Posted - 2009-04-14 : 19:51:40
you might need to convert the value.

select max(cast(temperatura as float)) as exp1 from tabla1
Go to Top of Page
   

- Advertisement -