P
PatdeLux
Hi all,
I have searched a lot about elegant workarounds to the lacks of
(COUNT(DISTINCT) in Access but haven't found an understandable reply
to my need (except in multiple queries)
Here is demand:
I have a Valuations table like this one:
ValDate Fund SubFund Amount
17/01/2008 AA A1 10
17/01/2008 AA A2 10.5
17/01/2008 AA A3 11
17/01/2008 BB B1 11.5
17/01/2008 BB B2 10
17/01/2008 BB B3 10.5
17/01/2008 BB B4 11
17/01/2008 CC C1 11.5
17/01/2008 CC C2 11
18/01/2008 BB B2 11.5
18/01/2008 BB B3 10
18/01/2008 BB B4 10.5
18/01/2008 CC C1 11
18/01/2008 CC C2 11.5
18/01/2008 AA A2 12
18/01/2008 DD D1 11
18/01/2008 DD D2 11.5
19/01/2008 AA A1 10
19/01/2008 AA A2 10.5
19/01/2008 BB B1 11
19/01/2008 BB B2 11.5
19/01/2008 BB B3 11.5
I want to calculate how many DISTINCT funds and subfunds I have
everyday, and get a result like this:
Date #Funds #SubFunds
17/1/08 3 9
18/1/08 4 8
19/1/08 2 5
I can do it with 2 queries but when can't get it working with 1 query
contining a subquery.
I tried something like this, but no success:
SELECT VDate, COUNT(*) as SubFundsCount, (SELECT COUNT(*) FROM (SELECT
DISTINCT fund FROM Valuations s WHERE s.VDate = main.VDate) as
FundsCount
FROM Valuations main;
Any idea or link ?
Thanks !
I have searched a lot about elegant workarounds to the lacks of
(COUNT(DISTINCT) in Access but haven't found an understandable reply
to my need (except in multiple queries)
Here is demand:
I have a Valuations table like this one:
ValDate Fund SubFund Amount
17/01/2008 AA A1 10
17/01/2008 AA A2 10.5
17/01/2008 AA A3 11
17/01/2008 BB B1 11.5
17/01/2008 BB B2 10
17/01/2008 BB B3 10.5
17/01/2008 BB B4 11
17/01/2008 CC C1 11.5
17/01/2008 CC C2 11
18/01/2008 BB B2 11.5
18/01/2008 BB B3 10
18/01/2008 BB B4 10.5
18/01/2008 CC C1 11
18/01/2008 CC C2 11.5
18/01/2008 AA A2 12
18/01/2008 DD D1 11
18/01/2008 DD D2 11.5
19/01/2008 AA A1 10
19/01/2008 AA A2 10.5
19/01/2008 BB B1 11
19/01/2008 BB B2 11.5
19/01/2008 BB B3 11.5
I want to calculate how many DISTINCT funds and subfunds I have
everyday, and get a result like this:
Date #Funds #SubFunds
17/1/08 3 9
18/1/08 4 8
19/1/08 2 5
I can do it with 2 queries but when can't get it working with 1 query
contining a subquery.
I tried something like this, but no success:
SELECT VDate, COUNT(*) as SubFundsCount, (SELECT COUNT(*) FROM (SELECT
DISTINCT fund FROM Valuations s WHERE s.VDate = main.VDate) as
FundsCount
FROM Valuations main;
Any idea or link ?
Thanks !