troubleshooting Question

How do I fix this Sql select statement ?

Avatar of mdcarr
mdcarr asked on
Microsoft SQL Server 2005
6 Comments1 Solution240 ViewsLast Modified:
Hello,

First thank you for your time.

My table is of the form:
Column1:  Column Name=Id, Data Type=int
Column2:  Column Name=Balance, Data Type=nvarchar(20)

The data in the table looks like this:
Row1:  1, $15,000.00
Row2:  2, $2.00
Row3:  3, -$15.45

When I execute this query:
select * from Clients where Balance > '$15'
 
I get the following result set returned:
Row1:  1, $15,000.00
Row2:  2, $2.00
Row3:  3, -$15.45

I was obviously only expecting to see Row1.

What is going on here?  I would like to use the nvarchar data type.  Is there a way to alter the structure of the query to get the proper result?  Or must I use the Money data type?

Thank you for your time.
Michael
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros