Solved

SQL Query Problem

Posted on 2009-07-08
4
256 Views
Last Modified: 2012-05-07
I have written the below query to select items from tblItems which have different balances than their counter parts in stblBalances. However, as you can see in the picture it is pulling up records with balances that should match. In both tables the balance fields are the same (Type: Double, Format: Fixed, Decimal Places: 3).

Why is this not pulling up the correct results?
SELECT a.ItemID, a.Balance, b.Balance, a.RequiresReview, a.Category, a.Completed

FROM tblItems AS a, stblBalances AS b

WHERE a.ItemID = b.ItemID AND a.Balance <> b.Balance

Open in new window

balances.bmp
0
Comment
Question by:bejhan
  • 2
4 Comments
 
LVL 41

Accepted Solution

by:
ralmada earned 175 total points
ID: 24806682
Maybe there are more decimals there. Can you try this?
SELECT a.ItemID, a.Balance, b.Balance, a.RequiresReview, a.Category, a.Completed

FROM tblItems AS a, stblBalances AS b

WHERE a.ItemID = b.ItemID AND round(a.Balance,3) <> round(b.Balance,3)

Open in new window

0
 
LVL 1

Author Comment

by:bejhan
ID: 24806701
Ah shoot I should have known, I was having a similar problem with conditional formatting. I just figured SQL would be able handle that problem. Thanks!
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24806761
rounding, I presume.
the display is rounded, but the values do indeed not match

round(a.Balance) <> round(b.Balance)

Open in new window

0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 24806764
too slow :(
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now