Solved

Weird query results

Posted on 2014-12-25
2
137 Views
Last Modified: 2014-12-25
Hi Experts,
I am trying to figure out a strange Access/SQL behavior as follows.
I have a query that when displaying only 1 column it gives me one quantity of records and when displaying 2 columns it gives me a different qty.
Query1
SELECT DISTINCT TmpPatBillingCodes.PatientsID, #12/31/2013# AS Expr1
FROM TmpPatBillingCodes
WHERE (((#12/31/2013#) Between [effectivefrom] And [end]));

Open in new window

Query2
SELECT DISTINCT TmpPatBillingCodes.PatientsID, #12/31/2013# AS Expr1, TmpPatBillingCodes.EffectiveFrom
FROM TmpPatBillingCodes
WHERE (((#12/31/2013#) Between [effectivefrom] And [end]));

Open in new window

Can someone help me figure out?
0
Comment
Question by:bfuchs
2 Comments
 
LVL 39

Accepted Solution

by:
als315 earned 500 total points
Comment Utility
You are using SELECT DISTINCT and if you have following table:
1 2
1 2
1 3

in first query (one column) result will be:
1
in second (two columns):
1 2
1 3

Remove DISTINCT and compare quantity of records
http://office.microsoft.com/en-001/access-help/all-distinct-distinctrow-top-predicates-HP001032205.aspx
0
 
LVL 3

Author Closing Comment

by:bfuchs
Comment Utility
Ooops, I didn't realized that as this was copied from another query...
Thank you!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

771 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

11 Experts available now in Live!

Get 1:1 Help Now