Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Max and Min with the Money datatype

Status
Not open for further replies.

HIC

Technical User
Apr 24, 2002
3
US
When I try to get the max and min of a column with a money datatype it brings back 1000 as min and 999 as max. Obviously, I need 1000 to be the max. I have tried to cast and convert this to different datatypes, but have been unable to make this work properly. Any ideas?

Thanks!

HIC
 
Are you sure the 1000 is not a negative number and you are stripping off the sign somehow?

Show a copy of your SQL statement.

Have you verified through Query Analyzer or other means the actual low and high values in the table?
 
Thanks for the reply

I have a table of 10 rows. All have either a 999 or 1000 in a field called Money.

Select Emp_id, min(Money)as minimum, max(Money) as maximum from testtable where emp_id=3456
group by emp_id
 
It should work are you sure you are not reversing the names min and max in the AS definition.

I tried several scenarios and always got the expected results. Is this sql server 2000?
 
Are you SURE the *data type* is MONEY (not just the column name!)? and not
CHAR?

If it is a char type 1000 is indeed less than 999

declare @a char(4)
declare @b char(4)

set @a = '1000'
set @b = '999'

if (@a < @b)
print 'less'
 
I would like to hear how this issue turned out.
I thought cmmrfrd's and sagn's suggestions were pretty good.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top