473,386 Members | 1,817 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,386 software developers and data experts.

Place duplicates in separate columns

4
Hi there,
I'm stuck here and would appreciate any nudges or ideas! My basic scenario is this - I have a table with duplicate records and I need to take the values from the duplicate records and place them into separate columns. The table structure is similar to this (sorry - periods are being used as separators):

SAMPLE....VALUE
G1234...........50
G1234...........68

What I'm aiming for is something like this (preferably stored in a query):
SAMPLE....VALUE1....VALUE2
G1234............50..............68

I realize that this is not ideal! But this is what the client wants/needs for comparison purposes.

Can this be done via SQL/VBA? I know that I could potentially use an SQL find duplicates query to at least count the duplicates, but that ends up with a count and not the actual values.

Even explaining the logic required would help! I'm using Access 2003 on XPSP2.

Thank you,
Olwyn
Nov 15 '07 #1
3 1387
FishVal
2,653 Expert 2GB
Hi, Olwyn.

The issue looks to be complicated. So far I don't see how it may be implemented as query, but via temporary table. On the other hand you may easily build a query returning the following results

SAMPLE....VALUE
G1234...........50
G1234...........68

SAMPLE....VALUES_LIST
G1234............50, 68

Would this fit your needs?

Regards,
Fish
Nov 17 '07 #2
nfrjob
4
Hi Fish!
Yep, it's complicated alright...
I never thought about the concatenation aspect - it *might* work, I'll have to clarify with the client. I suspect it may not be the answer.
My new(?) plan that I'm working on is to load the duplicate samples into an array, then use another array to store the values...much more complicated though...
Cheers,
Olwyn
Hi, Olwyn.

The issue looks to be complicated. So far I don't see how it may be implemented as query, but via temporary table. On the other hand you may easily build a query returning the following results

SAMPLE....VALUE
G1234...........50
G1234...........68

SAMPLE....VALUES_LIST
G1234............50, 68

Would this fit your needs?

Regards,
Fish
Nov 19 '07 #3
If you have no more than two duplicates, you could try something like this:

SELECT SAMPLE, Min(VALUE) AS VALUE1, Max(VALUE) AS VALUE2
FROM YourTable
GROUP BY SAMPLE
HAVING COUNT(*) > 1
Nov 22 '07 #4

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

Similar topics

1
by: Joe Narissi | last post by:
I have a table, TEST_TABLE, with 6 columns (COL1, COL2, COL3, COL4, COL5, COL6).... I need to be able to select all columns/rows where COL3, COL4, and COL5 are unique.... I have tried using...
3
by: Shawn | last post by:
Hi guys, I'm trying to compose a query that will select all columns from a table, but without any duplicates. E.g. table name is 'tblShipment' columns are: fldUnique(pk) | fldShipNo |...
3
by: kjaggi | last post by:
I am trying to either write a trigger or a check constraint to prevent duplicates in my table. There are two columns I need to look at for the duplicates and only one combo value for both columns...
3
by: bellefy | last post by:
Hi All, I have a fairly large table with approx 30K rows that updates every night via a cron script that automatically downloads the 2 new csv's. The problem is the files are downloaded from...
16
by: tyrfboard | last post by:
I've been searching for awhile now on how to remove duplicates from a table within an Access db and have found plenty of articles on finding or deleting duplicates. All I want to do is remove them...
8
by: Mark | last post by:
Let's say I have a table of users, and each user has a list of categories. I could store each user's categories as TEXT with delimeters like "cat1|cat2|cat3" But then I need to be able to get a...
4
by: yin_n_yang74 | last post by:
I am new to SQL and SQL Server world. There must be a simple solution to this, but I'm not seeing it. I am trying to create a crystal report (v8.5) using a stored procedure from SQL Server...
3
by: staja84f | last post by:
I'm trying to locate duplicate data in a table using 4 columns: employee_id (primary key), employeeid, lastname and firstname. I can pull up the duplicate data with the last three listed columns,...
1
by: KimmyG | last post by:
I'm just starting to use SQL and am much more experienced in Access. Here is what I do in Access Copy a table and rename the new table "copytable" also select structure only. Open "copytable"...
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:
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.