473,406 Members | 2,954 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,406 software developers and data experts.

Create query to sort data and autoincrement associated column

Hi, I'm new to this group and fairly new to Access. I have a bunch of
data, and after several other queries, I generate the following query
which has two fields:

Bin, Time
20 3.5
20 3.9
20 4.6
40 2.4
40 2.7
40 3.4
40 5.6

except the real query has about 120 rows, with the first field
(probability bin) taking the values of {20,40,60,80,100} and the second
field (time) taking any real positive number.

For each bin (20 and 40 in the above sample) I want to generate a new
set of data. This data set should consist of the second field (time)
sorted in ascending order, and then an additional field which
increments from 0 to the number of the bin. For example, using the
above sample, I would get the following data:

(For bin=20)
3.5 0
3.9 10
4.6 20

(for bin=40)
2.4 0
2.7 13.3
3.4 26.6
5.6 40
I've had a lot of trouble thinking of some way to do this. Of course
the first step can be to create an intermediate query which only picks
out the numbers from a desired bin, but then I'm still left with
sorting the times and autoincrementing that second field. Thanks for
any tips or suggestions,
-mael

Apr 14 '06 #1
2 5453
Simplest to understand (maybe)

In VBA module
1) create query to give you the BIN and # records in each BIN

2) bounce thu that query and
a) create query to select from the first from the first query
ranged down to the BIN you are sitting on
b) bounce through that query and
i. create record with the time from the record you are on
and the BIN / (# of records for the BIN less 1) times (the count of
the record for that BIN that you are sitting on less 1). For the first
and last record use different logic {I do not know what you want if
there is only 1 time}.
ii. Also on the last one of them you want to put the BIN
number there instead of the computed figure, otherwise if you have 3
records, for example, the last one will not equal the BIN. also except
for the condition of only 1 record.
iii for the first record use 0 except for the only 1
condition which I do not know what you want to be loaded.

Ron

Apr 14 '06 #2
Thanks Ron,
Success! I mostly followed what you said.

Using DoCmd.RunSQL I did CREATE TABLE for each of the 5 "sets" I
wanted, then used INSERT INTO to pull of the times and put them into
these tables. Then I used a While loop to go through each RecordSet of
each table, and increment the column from 0 on up. Thanks again,
-mael

Apr 14 '06 #3

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

Similar topics

0
by: Marko Maehner | last post by:
Hi, I have a strange problem with my xml file. In the schema of this xml file I have set one column to autoincrement. When I enter the data in my xml file directly, the autoincrement-column gets...
8
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I...
1
by: Shapper | last post by:
Hello, I am trying to get some data from a XML file into a repeater: MyXML.ReadXml("http://www.mydomain.com/myXmlFile.xml") MyRepeater.DataSource = MyXML MyRepeater.DataBind() My XML file...
6
by: Dennis | last post by:
I have set a DataTable and one of the columns I set "AutoIncrement" to True. I then populate the Table by setting the columns to values then add the row to the table. I inadverently set the...
5
by: JC Voon | last post by:
Hi: How to reset the autoincrement value generated by DataTable ? I've master and detail table, the detail table has a autoincrement column, each time i add a new master record, i need to...
2
by: shuckjunkmail | last post by:
It was suggested that I re-submit this question as a new post rather than adding onto an old and unanswered post. The basic problem has to do with the .NET datagrid and sorting. I am having...
2
by: Anantha | last post by:
Dear All, One day our Windows 2000 Server OS crashed, so our NT admin has re-installed the OS on C: drive. Fortunately we kept our database file and installation in F: drive. When we...
27
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
12
by: tekctrl | last post by:
Environment; Win2K PC with 1Gb of RAM and plenty of HD space running Access 2002 Issue; Access presents a blank data entry form in the Forms view when the New Record icon is used. However, it...
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...
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:
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.