Solved

Weird query results

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

861 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