Hello,
I have following problem:
table1
id / ArticleCode / ArticleColor
1 / 123 / blue
2 / 123 / blue
3 / 222 / green
4 / 333 / red
5 / 444 / blue
Out of this data I need to pick unique values to return:
1 / 123 / blue
3 / 222 / green
4 / 333 / red
5 / 444 / blue
so basically, i need to keep all the fields, but throw out only records that have duplicate ArticleCode
When I run a wizard to find duplicates, and include ID and ArticleColor, it returns all recods.
When I use COUNT([ArticleCode])=1 it returns only record w/o duplicates.
Please help me out
If I have to solve this, I'd simply create following query : - SELECT Table1.COLOR, Table1.CODE, First(Table1.ID) AS FirstOfID
-
FROM Table1
-
GROUP BY Table1.COLOR, Table1.CODE;
I tried above query and got desired result..
10 2037
You need a SELECT DISTINCT query. zmbd 5,501
Expert Mod 4TB
Respectfully Seth, That will not work, nor will "DISTINCTROW" in that the field [ID] contains a unique value. You really should try it in a test database, don't take my word for it... ;-)
Now, if OP does not need [ID] then you can include only the [ArticleCode] and [ArticleColor] in the query use either of the "DISTINCT" Predicates.
Thanks for reply, - select distinct *
-
from table1
still will return all the records because of unique ID
If I only SELECT DISTINCT on ArticleCode then ok, but problem is that I need the ID.
What Now?
zmbd 5,501
Expert Mod 4TB
AH, Thank You for attempting the SQL.
You really should read my post. It would have saved you some frustration.
I have one solution that I use quite often for things like this... took me ages to figure out and as it is not straight forward try the following:
I actually have a template table and query set for this:
tbl_test
PK is the primary key, - SELECT [test_PK],
-
[Test_Field1],
-
[Test_Field2]
-
FROM [tbl_test] AS t1
-
WHERE NOT EXISTS
-
(SELECT 1
-
FROM [tbl_test] AS t2
-
WHERE [t2]![test_field1] = [t1]![test_field1]
-
AND
-
[t2]![test_field2] = [t1]![test_field2]
-
AND
-
[t2]![test_pk] <[t1]![test_pk]);
Now I hope Rabbit or NeoPa have something more elegant :)
Duh. I'm not sure what I was thinking, but I clearly missed the ID field throwing off the DISTINCT query results.
If I have to solve this, I'd simply create following query : - SELECT Table1.COLOR, Table1.CODE, First(Table1.ID) AS FirstOfID
-
FROM Table1
-
GROUP BY Table1.COLOR, Table1.CODE;
I tried above query and got desired result..
zmbd 5,501
Expert Mod 4TB
Told you there had to be a better method for your data set... the query I posted is a much shorter one I use against 16 fields... it's an old database that was not designed very well by one of my predecessors; however, given what it does, it's impressive (but slow).
I never thought to re-work it for smaller datasets...
Wow. Problem Solved! Thanks
If you post what solves your problem, it will be beneficial for other readers.
thanks.
NeoPa 32,556
Expert Mod 16PB Narender:
If you post what solves your problem, it will be beneficial for other readers.
I suspect you misunderstand. My understanding from reading through the thread is that your post (which I've now selected as Best Answer) was exactly the breakthrough they were looking for.
@Jacejwbak.
I hope you noted that many experts were confused by your question asking for one thing, then indicating with the example something quite different. Seth actually answered the question perfectly, but that wasn't what you needed because the question was asked wrong. Typically, the clearer the question is, the quicker and more easily you will find an answer posted.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: phill86 |
last post by:
Hi,
I have an access 2010 database that I want to convert to an SQL Server database and I need to know if the data macros in access will still work in the SQL database or will i have to create...
|
by: jaad |
last post by:
Hello,
I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta.
When I...
|
by: sierra7 |
last post by:
It seems Access 2010 is associating an 'input mask' or field type with a combo box when a form is opened, even though there is no Format setting on the control.
I have a form which has been...
|
by: dougancil |
last post by:
I have a user who had deleted some records from a database today using Access 2010. They have an ID field that's autonumbered. They have No Duplicates allowed. When they created a new record today,...
|
by: Andolino |
last post by:
In Access 2010 I get a Write Conflict error - "This record
has been changed by another user..."
In Access 2007 this Code is working - why?
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim...
|
by: Alan Yim |
last post by:
Hi folks,
My company recently upgraded our Office suite from 2003 to 2010. The problem in particular is with an Access database that was originally designed in Access 2003. The code in question...
|
by: colsoft |
last post by:
I am using Access 2010. Am generating reports for the records, one record per page.
The records on the even pages have a light black background shading which appears when am printing.
Please i need...
|
by: Bill Boord |
last post by:
I need to be able to shut off the AutoCorrect "feature" within Access 2010 code. I have utilized Application.SetOption with method strings for other startup requirements, but I cannot seem to find a...
|
by: dsatino |
last post by:
I have numerous applications built in Access 2000/2003 that all use ODBCdirect workspaces to access various non-Access databases. Unfortunately, ODBCdirect is 'no longer supported'in Access 2010 and...
|
by: Music Man |
last post by:
Greetings All:
I built a database in Microsoft SQL Server 2000 and used Microsoft Access 2010 as the front end. The database is used to keep track of "issues" that rise out of my employment. ...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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...
|
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...
|
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: 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...
| |