My table looks like this...
PersonID Data1 Data2
1 XXXX YYYY
1 BBBB YYYY
2 BBBB YYYY
3 XXXX YYYY
I'd like it to look like this...
PersonID SubRank Data1 Data2
1 1 XXXX YYYY
1 开发者_Python百科 2 BBBB YYYY
2 1 BBBB YYYY
3 1 XXXX YYYY
The closest solution I've come up with looks like this... (ID is the database access unique ID)
SELECT TABLE.PersonID, DCount("ID","Table","(PersonID='"&[PersonID]&"')",) AS SubRank, Table.Data1, Table.Data2
FROM Table
ORDER BY Table.PersonID;
But that only returns the total value for the the unique rows (i.e. Subrank is "2" both times for PersonID #1). Eventually this query will feed a crosstab query to get all the data for a single personID onto one row.
I grabbed the solution above from here: http://www.ozgrid.com/forum/showthread.php?t=39231&page=1
I'd like to accomplish the same goal, however, their code just isn't working.
Thanks!
You need to narrow the domain. You can see in the solution that he has
and
(Date <= #" & [Date] & "#)")
inside of the dcount function. So you need to do something like that as well -- though I'd imagine you're going to use ID instead of date. Maybe something like this:
DCount("ID","Table","(PersonID='"&[PersonID]&"') and (PersonID <= " & [PersonID] & ")" )
Your goal is a little vague here. Do you want to find the count of duplicates? Do you want to un-duplicate? Why not do this:
SELECT count(*), Data1, Data2 FROM Table GROUP BY Data1, Data2
精彩评论