Jumat, 13 Januari 2023

Re: [MSAccessProfessionals] Identify non-unique fields in a column

I expect a DCount() would work. 

Select *, IIf(DCount("*","Your Table Name","InvoiceNum='" & [InvoiceNum] & "'")>1, "Yes","No") As MultipleOrder
FROM …

Duane


On Jan 13, 2023, at 12:30 PM, Sean Cooper via groups.io <smcjb=yahoo.com@groups.io> wrote:


Greetings All.

I know that you can easily use Access to identify "Unique Records" but this is slightly different.

Imagine I have a simple table with CustomerID, ProductID & InvoiceNum but I want create a query with an additional column "MultipleOrder" which identifies if an Invoice has more than one product on it. ie if the InvoiceNum is not unique then it is a multiple order.

Hence the resulting query would like this


Obviously I can do this by creating two queries, the first to count how many records there are for each InvoiceNum and then a second query referencing both the table and the query to identify InvoiceNum with a count greater than one.

Is there a way to do this all in one query though?

Thanks, Sean



Tidak ada komentar:

Posting Komentar