Solved

SQL Query Problem

Posted on 2009-07-08
4
255 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

759 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

21 Experts available now in Live!

Get 1:1 Help Now