fransanchezoria
New member
- Local time
- Today, 12:37
- Joined
- Jun 27, 2011
- Messages
- 7
Hi,
As the title says, I need to do a count for distinct values in two columns. For example:
IPC Family ID Another ID
A01C 40059407 4764
A01C 41665653 399
A01C 41665653 1941
A01D 34009322 8415
A01D 34035545 8533
A01D 34035545 8530
A01D 34035545 8531
A01D 38043120 5580
The desired result would be:
IPC Count ofFamily ID CountofanotherID
A01C 2 3
A01D 3 5
I managed to do a distinct count in the first column with a subquery, however I can't get to work the distinct count for the second one.
This is the code I have so far:
Thank you beforehand!
As the title says, I need to do a count for distinct values in two columns. For example:
IPC Family ID Another ID
A01C 40059407 4764
A01C 41665653 399
A01C 41665653 1941
A01D 34009322 8415
A01D 34035545 8533
A01D 34035545 8530
A01D 34035545 8531
A01D 38043120 5580
The desired result would be:
IPC Count ofFamily ID CountofanotherID
A01C 2 3
A01D 3 5
I managed to do a distinct count in the first column with a subquery, however I can't get to work the distinct count for the second one.
This is the code I have so far:
Code:
SELECT [Chalmers Patents (w2 & namecheck)].[IPC Subclass] AS Expr1, Count([Chalmers Patents (w2 & namecheck)].[Family ID]) AS [Unique patents], Count([Chalmers Patents (w2 & namecheck)].[ID]) AS Applications
FROM (SELECT DISTINCT [Chalmers Patents (w2 & namecheck)].[Family ID], [Chalmers Patents (w2 & namecheck)].[ID], [Chalmers Patents (w2 & namecheck)].[IPC Subclass], [Chalmers Patents (w2 & namecheck)].[Name check] FROM [Chalmers Patents (w2 & namecheck)]) AS [%$##@_Alias]
GROUP BY [Chalmers Patents (w2 & namecheck)].[IPC Subclass], [Chalmers Patents (w2 & namecheck)].[Name check]
HAVING ((([Chalmers Patents (w2 & namecheck)].[IPC Subclass]) Is Not Null) AND (([Chalmers Patents (w2 & namecheck)].[Name check])="check"));
Thank you beforehand!