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

Group Data/Copy Row Two Field to Row One Field

I am having trouble figuring this one out... Hopefully someone can
help!

I have a table ("tbl1")

It has five (5) fields:
1- "Item1"
2- "Item2"
3- "Item3"
4- "ScanImage" (stores scan path/filename)
5- "ID"

I can have an "order" with up to three Items. We scan the order and
create a "ScanImage" filename (row). In the past each order that had
multiple "Items" was "Cloned" and a duplicate "ScanImage" record was
created.

A sample of two orders with three items on each:

Item1 Item2 Item3 ScanImage ID
x1 scan1 1
y1 scan1 2
z1 scan1 3
a1 scan2 4
b1 scan2 5
c1 scan2 6

What I need to do is turn these six (6) records into two (2) by
populating the "Item2" and "Item3" fields using the "ScanImage" as the
unique id.

So the set should look like this:

Item1 Item2 Item3 ScanImage
x1 y1 z1 scan1
a1 b1 c1 scan2

I know this is not an ideal schema (far from it) but I am required to
report the data in this format. I am trying to do this after the fact
(last year's data which was not keyed in correctly).

There are over 3000 individual records that need this "cleansing".

Thanks to all in advance.

-Bob

Jan 10 '06 #1
2 1545
de******@gmail.com wrote:
I am having trouble figuring this one out... Hopefully someone can
help!

I have a table ("tbl1")

It has five (5) fields:
1- "Item1"
2- "Item2"
3- "Item3"
4- "ScanImage" (stores scan path/filename)
5- "ID"

I can have an "order" with up to three Items. We scan the order and
create a "ScanImage" filename (row). In the past each order that had
multiple "Items" was "Cloned" and a duplicate "ScanImage" record was
created.

A sample of two orders with three items on each:

Item1 Item2 Item3 ScanImage ID
x1 scan1 1
y1 scan1 2
z1 scan1 3
a1 scan2 4
b1 scan2 5
c1 scan2 6

What I need to do is turn these six (6) records into two (2) by
populating the "Item2" and "Item3" fields using the "ScanImage" as the
unique id.

So the set should look like this:

Item1 Item2 Item3 ScanImage
x1 y1 z1 scan1
a1 b1 c1 scan2

I know this is not an ideal schema (far from it) but I am required to
report the data in this format. I am trying to do this after the fact
(last year's data which was not keyed in correctly).

There are over 3000 individual records that need this "cleansing".

Thanks to all in advance.

-Bob


Your schema disclaimer has been noted.

The first thing I tried was:

qryScanImage:
SELECT DISTINCT ScanImage AS theScanImage FROM tblClones;

qryItems:
SELECT (SELECT FIRST(A.Item1) FROM tblClones As A WHERE A.ScanImage =
qryScanImage.theScanImage) AS Item1, (SELECT FIRST(A.Item1) FROM
tblClones As A WHERE A.ScanImage = qryScanImage.theScanImage AND
A.Item1 <> (SELECT FIRST(B.Item1) FROM tblClones As B WHERE B.ScanImage
= qryScanImage.theScanImage)) AS Item2, (SELECT FIRST(A.Item1) FROM
tblClones As A WHERE A.ScanImage = qryScanImage.theScanImage AND
A.Item1 <> (SELECT FIRST(B.Item1) FROM tblClones As B WHERE B.ScanImage
= qryScanImage.theScanImage) AND A.Item1 <> (SELECT FIRST(B.Item1) FROM
tblClones As B WHERE B.ScanImage = qryScanImage.theScanImage AND
B.Item1 <> (SELECT FIRST(C.Item1) FROM tblClones As C WHERE C.ScanImage
= qryScanImage.theScanImage))) AS Item3, theScanImage AS ScanImage FROM
qryScanImage;

I didn't make any attempt to optimize this. The ID field will suggest
to Access to use that for a default order when viewing tblClones so
that's the order you should get for Item1, Item2 and Item3. Item2
finds the first item, if any, that is not equal to the first. Item3
finds the first item, if any, that is not equal to the first or to the
second. A more general solution might use a ranking within a ScanImage
based on ID. Post back if you need something better.

James A. Fortune
CD********@FortuneJames.com

Jan 10 '06 #2
Thank you James! That did the trick.

Bob

Jan 11 '06 #3

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

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
by: X | last post by:
I have a varchar field which contains a comma delimeted set of data. I am trying to us the ELT function to extract the first part of the group. Problem is, ELT does not seem to work when the data...
4
by: Andy Hutchings | last post by:
Hi everybody - hope you can help out here. I have a form in a database, which is a columnar form from one of the tables in the db - there is a sub-form to the form which is a datasheet view of...
8
by: Jerry | last post by:
I have an off-the-shelf app that uses an Access database as its backend. One of the tables contains a field with an "OLE Object" datatype. I'm writing some reports against this database, and I...
3
by: Jack | last post by:
I am currently trying to work on a program and I found it more convient to have a tempory object which would hold a copy of data loaded from a file so I wouldn't have to work with the overhead of...
8
by: siol | last post by:
Hy! I have htmleditor (from the microsoft's samples page) embeded into my asp.net page. Editor generates some html code inside <div id="oDiv"></div> tags. And what I would like to do is return...
0
by: dba123 | last post by:
THERE HAS TO BE A SOLUTION FOR THIS!!!! How can I get around the limitation in SSRS 2005 of being able to SUM a Group referenced field in my FOOTER!!! It's driving me nuts My footer field's...
20
by: TC | last post by:
I need an automated procedure to copy data from an Access table to a SQL Server table. Speed is important. What is the recommended technique? I can export the data from Access, copy it via FTP,...
8
by: ALTAFAD | last post by:
How to copy selected (s) textfield, which those selected through checkbox I like to copy in clipboard. Access textfield data when front of the textfield checkbox is checked if not checked 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.