Solved

SQL Query Problem

Posted on 2009-07-08
4
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 143

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 143

Expert Comment

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

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

690 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