Hi,
I (really urgent) need to get rid of double records in the result of a query.
Any help would be highly appreciated!
My database looks like this:
orders.partno
orders.date
orders.data1
orders.data2
orders.data3
I need to write an SQL-query that gives me all the fields from the table above as result, but every partno should only exist ONCE (means "removing" any double partno records). Important is that when there are double partno records, it should keep the record with the most recent orders.date (if there are several records with the same orders.date for one orders.partno, it doesn't matter which of them is kept / removed).
I am unfortunately not experienced at all in SQL (I can read easy code but not write).
An employee working with SQL, but not for access, sent me this. He just hade time to sent me a general answer (below). I have not been able to transfer this proposal into a working SQL (where t would be my table orders above I assume):
His quick generic proposal:
select
distinct
t.a,
t.b,
(select MAX(c) from #test where a = t.a) as c
from #test t
I tried to write an SQL like this (with my table and fields):
select
distinct
orders.orderno,
orders.date,
orders.data1,
orders.data2,
orders.data3,
(select MAX(c) from #test where partno = orders.partno) as c
from #test orders
I get a syntax error on the select statement (I don't know if I correctly understood how the field c should be handled)
I hope you can help me out. Many thanks in advance!
I (really urgent) need to get rid of double records in the result of a query.
Any help would be highly appreciated!

My database looks like this:
orders.partno
orders.date
orders.data1
orders.data2
orders.data3
I need to write an SQL-query that gives me all the fields from the table above as result, but every partno should only exist ONCE (means "removing" any double partno records). Important is that when there are double partno records, it should keep the record with the most recent orders.date (if there are several records with the same orders.date for one orders.partno, it doesn't matter which of them is kept / removed).
I am unfortunately not experienced at all in SQL (I can read easy code but not write).
An employee working with SQL, but not for access, sent me this. He just hade time to sent me a general answer (below). I have not been able to transfer this proposal into a working SQL (where t would be my table orders above I assume):
His quick generic proposal:
select
distinct
t.a,
t.b,
(select MAX(c) from #test where a = t.a) as c
from #test t
I tried to write an SQL like this (with my table and fields):
select
distinct
orders.orderno,
orders.date,
orders.data1,
orders.data2,
orders.data3,
(select MAX(c) from #test where partno = orders.partno) as c
from #test orders
I get a syntax error on the select statement (I don't know if I correctly understood how the field c should be handled)
I hope you can help me out. Many thanks in advance!