Solved

Weird query results

Posted on 2014-12-25
2
143 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
[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 Comments
 
LVL 40

Accepted Solution

by:
als315 earned 500 total points
ID: 40517842
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 4

Author Closing Comment

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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

740 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