473,387 Members | 3,820 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.

Data matching within 10 integers - query

natalie99
Hi peeps!

I need to create a query that says two fields match if the numeric values are within 10 units of each other. I.E. not an exact match.

I do not want to 'round', as items could round in opposite directions eg.

15,481.2 and 15,474.5 are within ten increments of each other, but if I round to the nearest ten integers:

15,480 and 15,470 won't come up as matches.

Could someone pretty please detail the SQL to do this using query design layout if possible?

Any help will be very much appreciated :)

Nat
Mar 5 '08 #1
3 1668
Stewart Ross
2,545 Expert Mod 2GB
Hi peeps!

I need to create a query that says two fields match if the numeric values are within 10 units of each other. I.E. not an exact match.

I do not want to 'round', as items could round in opposite directions eg.

15,481.2 and 15,474.5 are within ten increments of each other, but if I round to the nearest ten integers:

15,480 and 15,470 won't come up as matches.

Could someone pretty please detail the SQL to do this using query design layout if possible?

Any help will be very much appreciated :)

Nat
Hi Nat. Rounding the values using the normal Round function (and not your interpretation of it!) is as good a way to go as any. You only need to round the values to a whole number, not to the nearest ten. The two values listed are 15,481.2 and 15,474.5, which round to 15,481 and 15,475 - and these rounded values are indeed within ten units of each other.

You don't tell us your table or field names, so you'll need to fill these in yourself in the generalised SQL below:

Expand|Select|Wrap|Line Numbers
  1. SELECT value1, value2 FROM sometable WHERE Abs(Round(value1, 0) - Round(value2, 0))<=10;
The Abs function returns the absolute value of a number (a positive value) regardless of whether it is positive or negative.

-Stewart
Mar 5 '08 #2
Hi Stewart

Thanks for the code!

SELECT value1, value2 FROM sometable WHERE Abs(Round(value1, 0) - Round(value2, 0))<=10;

I was unsure how to create the plus/minus 10 section, so the Abs function is perfect! So now in my testing only 1 of 48,000 records won't price, and it's a spelling mistake, woohoo success!

You may be able to help with my new problem, (sorry for the assumption!) now I have an auto-pricing inventory tool which exports the results to file etc etc etc.

The last thing I would like to do is either:

a) write an autorun at startup Macro to load the file to be priced into an existing table, (replacing current data in the file, the template is set up and will always match)

or

b) create a form with a borwse button and select a file to load in to be priced(same file, different method and data still needs to be replaced not added)

Any thoughts or suggestions would be lovely, I am such a db novice it is scary :)

Thanks again

Nat
Mar 5 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi Nat. I'm delighted you found the SQL solution useful.

On your new query it is better etiquette to create a new thread for a new question that does not relate directly to the old one.

Having said that, there are many possible options you could use to import data. You could use a macro to automate the process of importing an Excel file, say, or you could use a command button on a form to run the DoCmd.TransferSpreadSheet method in VB to do this for you. There are many possible options, but as you provide no details of the file format, file name, location, or contents I can only answer in the most general of terms.

In my opinion the simplest option for a novice is to check out the import options available via File, get external data, then create a macro to automate the process for you, and run this macro when you start the database. You could also consider linking to an Excel sheet (which would have to be the same name and location every time it is re-exported), instead of importing the data each time. With linked rather than imported tables you only have to set up the link once and the linked data is there each time you open the database thereafter.

-Stewart
Mar 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: news.west.cox.net | last post by:
Forgive me, I am new to javascript ( about 1 week playing with it ). I am proficient in C, perl, python, java, etc... but no javascript. I wrote an applet about 1 million years ago that has...
0
by: CSDunn | last post by:
Hello, I have a format issue on an Access 2000 ADP report that I am going to attempt to explain from a 'ten thousand foot view' : I have an Access 2000 ADP report that has a SQL Server 2000...
3
by: brian kaufmann | last post by:
Hi, I had sent this earlier, and would appreciate any suggestions on this. I need to make calculations for unemployment rate for three different data sources (A,B,C) for many countries and age...
4
by: BerkshireGuy | last post by:
Our IT department wants to place our Access 2000 tables on an SQL server due to the fact the tables are quite large. With that said, can we still use the Access queries or do we have to do...
1
by: meganrobertson22 | last post by:
hi everybody- what is the best way to add data from one form to another? i have 2 tables: person and contract. here are some of the fields. table: person personid (autonumber and primary...
0
by: Christoph Haas | last post by:
Hi, list... I have written an application in Perl some time ago (I was young and needed the money) that parses multiple large text files containing nested data structures and allows the user to...
4
by: so many sites so little time | last post by:
ok so i am having problems if you look at the script below you will see that it the query has 4 values to insert but the actual values only contain title entry and now() for the date. well i have...
1
by: steve | last post by:
I'm fairly new to Access and trying to figure out how to execute a particulary query. For example I have 2 tables named TEST and TEST1. TEST has a column labeled LETTERS with values A - Z. I want...
5
by: toralf | last post by:
Hello, I'm wondering how I can test whether a field matches a 10-digit integer within DB2. -- MfG/Sincerely Toralf Förster pgp finger print: 7B1A 07F4 EC82 0F90 D4C2 8936 872A E508 7DB6...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.