473,387 Members | 1,687 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

distinct (unique values) is not working

Hi,

Looking to see if someone might have an explanation for this behavior.
Is it a bug? Corruption?

I have been able to reproduce the problem with only 2 rows and 1
field. Here is the table:

Field1
231.2
231.2

where Field1 is a double.

When I run a query to select this field from the table and set "Unique
Values" to YES, it still gives me these two rows. It should give me
only one row because they're not unique. Here is the query:

SELECT DISTINCT Table_1field.Field4
FROM Table_1field;

Just to rule out that there might be hidden characters or something
like that making the two rows distinct, I copied and pasted the value
in one row to the other so they should be identical. But the query is
still returning both rows when "Unique Values" is set to YES.

More info:

- I used the Compact/Repair tool on the database and the problem
didn't go away.
- I imported the table into a brand new database. The problem didn't
go away.
- I copied the rows into a new table in a brand new database. The
problem DID go away.

Any ideas why this might be happening? This is a huge database and I'm
concerned this issue could be creating serious problems in my query
results. Would the best solution? Create a new database? And copy all
the data into from each table into a new table? Yikes. Lots of work!

Your ideas are appreciated.

Jun 18 '07 #1
6 8998
Your Select statement is referencing a 'Field4' not 'filed1', so
what's in field4?
bobh.

On Jun 18, 3:10 pm, shira <shira...@gmail.comwrote:
Hi,

Looking to see if someone might have an explanation for this behavior.
Is it a bug? Corruption?

I have been able to reproduce the problem with only 2 rows and 1
field. Here is the table:

Field1
231.2
231.2

where Field1 is a double.

When I run a query to select this field from the table and set "Unique
Values" to YES, it still gives me these two rows. It should give me
only one row because they're not unique. Here is the query:

SELECT DISTINCT Table_1field.Field4
FROM Table_1field;

Just to rule out that there might be hidden characters or something
like that making the two rows distinct, I copied and pasted the value
in one row to the other so they should be identical. But the query is
still returning both rows when "Unique Values" is set to YES.

More info:

- I used the Compact/Repair tool on the database and the problem
didn't go away.
- I imported the table into a brand new database. The problem didn't
go away.
- I copied the rows into a new table in a brand new database. The
problem DID go away.

Any ideas why this might be happening? This is a huge database and I'm
concerned this issue could be creating serious problems in my query
results. Would the best solution? Create a new database? And copy all
the data into from each table into a new table? Yikes. Lots of work!

Your ideas are appreciated.

Jun 18 '07 #2
Thanks for catching that, but it was just a typo when I wrote this
message. It is actually Field4 in both the table and query.

On Jun 18, 1:52 pm, bobh <vulca...@isp.comwrote:
Your Select statement is referencing a 'Field4' not 'filed1', so
what's in field4?
bobh.

On Jun 18, 3:10 pm, shira <shira...@gmail.comwrote:
Hi,
Looking to see if someone might have an explanation for this behavior.
Is it a bug? Corruption?
I have been able to reproduce the problem with only 2 rows and 1
field. Here is the table:
Field1
231.2
231.2
where Field1 is a double.
When I run a query to select this field from the table and set "Unique
Values" to YES, it still gives me these two rows. It should give me
only one row because they're not unique. Here is the query:
SELECT DISTINCT Table_1field.Field4
FROM Table_1field;
Just to rule out that there might be hidden characters or something
like that making the two rows distinct, I copied and pasted the value
in one row to the other so they should be identical. But the query is
still returning both rows when "Unique Values" is set to YES.
More info:
- I used the Compact/Repair tool on the database and the problem
didn't go away.
- I imported the table into a brand new database. The problem didn't
go away.
- I copied the rows into a new table in a brand new database. The
problem DID go away.
Any ideas why this might be happening? This is a huge database and I'm
concerned this issue could be creating serious problems in my query
results. Would the best solution? Create a new database? And copy all
the data into from each table into a new table? Yikes. Lots of work!
Your ideas are appreciated.


Jun 18 '07 #3
shira wrote:
Hi,

Looking to see if someone might have an explanation for this behavior.
Is it a bug? Corruption?

I have been able to reproduce the problem with only 2 rows and 1
field. Here is the table:

Field1
231.2
231.2

where Field1 is a double.

When I run a query to select this field from the table and set "Unique
Values" to YES, it still gives me these two rows. It should give me
only one row because they're not unique. Here is the query:

SELECT DISTINCT Table_1field.Field4
FROM Table_1field;

Just to rule out that there might be hidden characters or something
like that making the two rows distinct, I copied and pasted the value
in one row to the other so they should be identical. But the query is
still returning both rows when "Unique Values" is set to YES.

More info:

- I used the Compact/Repair tool on the database and the problem
didn't go away.
- I imported the table into a brand new database. The problem didn't
go away.
- I copied the rows into a new table in a brand new database. The
problem DID go away.

Any ideas why this might be happening? This is a huge database and I'm
concerned this issue could be creating serious problems in my query
results. Would the best solution? Create a new database? And copy all
the data into from each table into a new table? Yikes. Lots of work!

Your ideas are appreciated.
Are you sure the numbers are unique? Is the number displayed is
formatted to display 1 decimal point? IOW, could record 1 have 231.2 as
the value and the other be 231.201...and if the display is 1 decimal
then you'd get both rec's. Just guessing.
Jun 19 '07 #4
Although both fields look the same, internally they will be slightly
different values.

The Double has the rounding errors that are always associated with floating
point numbers. For an introduction to this issue, see:
http://en.wikipedia.org/wiki/Floatin...uracy_problems

If you will never need more than 4 decimal places, an alternative would be
to use a Currency field instead of a Double. (You can set the Format
property of the field so it doesn't display as money.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"shira" <sh******@gmail.comwrote in message
news:11********************@d30g2000prg.googlegrou ps.com...
Hi,

Looking to see if someone might have an explanation for this behavior.
Is it a bug? Corruption?

I have been able to reproduce the problem with only 2 rows and 1
field. Here is the table:

Field1
231.2
231.2

where Field1 is a double.

When I run a query to select this field from the table and set "Unique
Values" to YES, it still gives me these two rows. It should give me
only one row because they're not unique. Here is the query:

SELECT DISTINCT Table_1field.Field4
FROM Table_1field;

Just to rule out that there might be hidden characters or something
like that making the two rows distinct, I copied and pasted the value
in one row to the other so they should be identical. But the query is
still returning both rows when "Unique Values" is set to YES.

More info:

- I used the Compact/Repair tool on the database and the problem
didn't go away.
- I imported the table into a brand new database. The problem didn't
go away.
- I copied the rows into a new table in a brand new database. The
problem DID go away.

Any ideas why this might be happening? This is a huge database and I'm
concerned this issue could be creating serious problems in my query
results. Would the best solution? Create a new database? And copy all
the data into from each table into a new table? Yikes. Lots of work!

Your ideas are appreciated.
Jun 19 '07 #5
Thanks very much Allen. I will look into this. I'm just really
surprised that a number as seemingly simple as 231.2 is exhibiting
this problem. It only has 1 digit after the decimal.

The reason it was such a problem is that we were trying to find
duplicate records in the database (they were entered by mistake) and
were relying on this field to help match the duplicates. Since Access
couldn't see them as the same value, we were stuck. I then used the
round function using 5 decimal places (because some of my numbers have
more digits after the decimal than 231.2) and it seemed to then
identify same values as the same. I'm pleased to have a solution, but
I'm just wary that this issue may crop up again in other ways.

Thanks again.

On Jun 18, 6:56 pm, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
Although both fields look the same, internally they will be slightly
different values.

The Double has the rounding errors that are always associated with floating
point numbers. For an introduction to this issue, see:
http://en.wikipedia.org/wiki/Floatin...uracy_problems

If you will never need more than 4 decimal places, an alternative would be
to use a Currency field instead of a Double. (You can set the Format
property of the field so it doesn't display as money.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"shira" <shira...@gmail.comwrote in message

news:11********************@d30g2000prg.googlegrou ps.com...
Hi,
Looking to see if someone might have an explanation for this behavior.
Is it a bug? Corruption?
I have been able to reproduce the problem with only 2 rows and 1
field. Here is the table:
Field1
231.2
231.2
where Field1 is a double.
When I run a query to select this field from the table and set "Unique
Values" to YES, it still gives me these two rows. It should give me
only one row because they're not unique. Here is the query:
SELECT DISTINCT Table_1field.Field4
FROM Table_1field;
Just to rule out that there might be hidden characters or something
like that making the two rows distinct, I copied and pasted the value
in one row to the other so they should be identical. But the query is
still returning both rows when "Unique Values" is set to YES.
More info:
- I used the Compact/Repair tool on the database and the problem
didn't go away.
- I imported the table into a brand new database. The problem didn't
go away.
- I copied the rows into a new table in a brand new database. The
problem DID go away.
Any ideas why this might be happening? This is a huge database and I'm
concerned this issue could be creating serious problems in my query
results. Would the best solution? Create a new database? And copy all
the data into from each table into a new table? Yikes. Lots of work!
Your ideas are appreciated.

Jun 20 '07 #6
You might want to see what you can Google on how computers store Floating
Point numbers... it's a "computer feature", not an "Access problem". It is
a case of "what you see isn't what you get."

Larry Linson
Microsoft Access MVP

"shira" <sh******@gmail.comwrote in message
news:11*********************@i38g2000prf.googlegro ups.com...
Thanks very much Allen. I will look into this. I'm just really
surprised that a number as seemingly simple as 231.2 is exhibiting
this problem. It only has 1 digit after the decimal.

The reason it was such a problem is that we were trying to find
duplicate records in the database (they were entered by mistake) and
were relying on this field to help match the duplicates. Since Access
couldn't see them as the same value, we were stuck. I then used the
round function using 5 decimal places (because some of my numbers have
more digits after the decimal than 231.2) and it seemed to then
identify same values as the same. I'm pleased to have a solution, but
I'm just wary that this issue may crop up again in other ways.

Thanks again.

On Jun 18, 6:56 pm, "Allen Browne" <AllenBro...@SeeSig.Invalidwrote:
>Although both fields look the same, internally they will be slightly
different values.

The Double has the rounding errors that are always associated with
floating
point numbers. For an introduction to this issue, see:
http://en.wikipedia.org/wiki/Floatin...uracy_problems

If you will never need more than 4 decimal places, an alternative would
be
to use a Currency field instead of a Double. (You can set the Format
property of the field so it doesn't display as money.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"shira" <shira...@gmail.comwrote in message

news:11********************@d30g2000prg.googlegro ups.com...
Hi,
Looking to see if someone might have an explanation for this behavior.
Is it a bug? Corruption?
I have been able to reproduce the problem with only 2 rows and 1
field. Here is the table:
Field1
231.2
231.2
where Field1 is a double.
When I run a query to select this field from the table and set "Unique
Values" to YES, it still gives me these two rows. It should give me
only one row because they're not unique. Here is the query:
SELECT DISTINCT Table_1field.Field4
FROM Table_1field;
Just to rule out that there might be hidden characters or something
like that making the two rows distinct, I copied and pasted the value
in one row to the other so they should be identical. But the query is
still returning both rows when "Unique Values" is set to YES.
More info:
- I used the Compact/Repair tool on the database and the problem
didn't go away.
- I imported the table into a brand new database. The problem didn't
go away.
- I copied the rows into a new table in a brand new database. The
problem DID go away.
Any ideas why this might be happening? This is a huge database and I'm
concerned this issue could be creating serious problems in my query
results. Would the best solution? Create a new database? And copy all
the data into from each table into a new table? Yikes. Lots of work!
Your ideas are appreciated.


Jun 20 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Florian | last post by:
Hi, I have a table that contains log data, usually around a million records. The table has about 10 columns with various attributes of the logged data, nothing special. We're using SQL Server...
8
by: Rich | last post by:
My table looks like this: char(150) HTTP_REF, char(250) HTTP_USER, char(150) REMOTE_ADDR, char(150) REMOTE_HOST, char(150) URL, smalldatetime TIME_STAMP There are no indexes on this table...
5
by: Fred Zuckerman | last post by:
Can someone explain the difference between these 2 queries? "Select Distinct id, account, lastname, firstname from table1" and "Select DistinctRow id, account, lastname, firstname from table1" ...
1
by: Don Bowman | last post by:
I have a table with a large number of rows (10K in the example below, but >1M in some databases). I would like to find the distinct values for one of the columns. The column is indexed. I would...
6
by: zaphod | last post by:
I need to select unique combinations of 4 columns from one table and insert them into a new table but I can't think of any way of finding unique combinations of more than 1 column since SELECT...
5
by: Daniel Wetzler | last post by:
Dear MSSQL experts, I use MSSQL 2000 and encountered a strange problem wqhile I tried to use a select into statement . If I perform the command command below I get only one dataset which has...
1
by: erbrose | last post by:
Hey, I keep searching the forum, but can't exactly what I need. I have a table (tbl_road) with tons of fields. I need to create a new table (tbl_road_distinct) with unique values of an field...
0
by: NeoGeo | last post by:
I have a problem with a SQL SELECT query. As far as my research goes i figured out that UNIQUE is used when you have one column that you whant unique and DISTINCT is used when you have more than one...
1
newnewbie
by: newnewbie | last post by:
Desperately need help in creating a query to count unique values in a table. I am a Business analyst with limited knowledge of Access….My boss got me ODBC connection to the underlying tables for our...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.