Solved

Weird query results

Posted on 2014-12-25
2
145 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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
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 …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

691 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