473,657 Members | 2,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1560
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.th eScanImage) AS Item1, (SELECT FIRST(A.Item1) FROM
tblClones As A WHERE A.ScanImage = qryScanImage.th eScanImage AND
A.Item1 <> (SELECT FIRST(B.Item1) FROM tblClones As B WHERE B.ScanImage
= qryScanImage.th eScanImage)) AS Item2, (SELECT FIRST(A.Item1) FROM
tblClones As A WHERE A.ScanImage = qryScanImage.th eScanImage AND
A.Item1 <> (SELECT FIRST(B.Item1) FROM tblClones As B WHERE B.ScanImage
= qryScanImage.th eScanImage) AND A.Item1 <> (SELECT FIRST(B.Item1) FROM
tblClones As B WHERE B.ScanImage = qryScanImage.th eScanImage AND
B.Item1 <> (SELECT FIRST(C.Item1) FROM tblClones As C WHERE C.ScanImage
= qryScanImage.th eScanImage))) 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********@Fort uneJames.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
11753
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 table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
0
1306
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 comes from a field. If I take the data and do, select elt(1,"red","green","blue") RESULT would be "red" But if the data was stored in a field (called group) and I did:
4
6805
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 another table in the db. The LinkChilds property is set to show connected records from both tables. What I'd like to do is copy and paste, or use some other method of writing, the contents of one field in one table in the form, to a field in the...
8
25381
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 believe this field contains data I need. When I view the table in datasheet view, all I can see in this field is the string "Long binary data". So, I've got the problem of needing to extract data from this field, but I don't know what format...
3
1536
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 loading from a file repeatedly. My problem is that when I store the temporary object to another object, changing the temporary object or its data also changes the data of the other object. Example: MyClass a=new MyClass(2), b=new MyClass(3);
8
6845
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 oDiv.InnerHtml to my "codebehind" (C#) where I would do additional tasks on it. If I do postback the oDiv content is lost. Can anyone help me how to send those data back to codebehind?
0
6227
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 expression (where the problem lies): =SUM(Fields!GrossGoal1.Value, "CustomerNumber_Grp") The GrossGoal1 group field that I'm trying to reference right above it in the same table column has: =((Fields!FeeGoal.Value) / Fields!FeeSchedule.Value)...
20
37881
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, then import it into SQL Server. I've tried that, and the speed is acceptable. It is an ugly solution, however, and I expect to find a better one -- preferably a solution better integrated with the Access RDBMS. I've tried using an ODBC...
8
6216
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 should not copy in clipboard. If text field has data like that altaf/ahmed mr one field checked goodguydude@thisandthatandtheother.com one field checked...
0
8399
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8606
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7337
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6169
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.