[AccessD] calculation

Gustav Brock Gustav at cactus.dk
Tue Jul 14 11:16:48 CDT 2009


Hi Pedro 

You need as well to finish the SQL statement to include your tablename:

Select 
  Patient, 
    Dcount("*","[Test]","Patient = '" & Patient & "' AND B = 3") / 
    Dcount("*","[Test]","Patient = '" & Patient & "'") * 100 As
  Percentage_B3
From
  tblYourTable
Group  by 
  Patient;

/gustav


>>> pedro at plex.nl 14-07-2009 15:06:02 >>>
Hello Gustav,

yu have a great look.
Indeed there was one after the second '" & Patient &.
But i still receive a syntaxerror, operator is missing. Then    group    is 
selected.

Pedro


----- Original Message ----- 
From: "Gustav Brock" <Gustav at cactus.dk>
To: <accessd at databaseadvisors.com>
Sent: Monday, July 13, 2009 10:33 PM
Subject: Re: [AccessD] calculation


>- and Pedro left out another one ...:
>
> Select Patient,Dcount("*","[Test]","Patient = '" & Patient & "' AND B = 3") /
> Dcount("*","[Test]","Patient = '" & Patient & "'") * 100 Group  by Patient;
>
> /gustav
>
>
>>>> stuart at lexacorp.com.pg 13-07-2009 20:34 >>>
> I missed a closing quote after the 3.
>
> Select Patient,Dcount("*","[Test]","Patient = '" & Patient & "' AND B = 3") /
> Dcount("*","[Test]","Patient = '" & Patient & "') * 100 Group  by Patient;
>
> On 13 Jul 2009 at 19:13, Pedro Janssen wrote:
>
>> Hello Stuart,
>>
>> i called my Table Test, but i get syntaxerrors (operator is missing).
>>
>> Which is missing?
>>
>> Select Patient,Dcount("*","[Test]","Patient = '" & Patient & "' AND B = 3) /
>> Dcount("*","[Test]","Patient = '" & Patient & "') * 100 Group  by Patient;
>>
>>
>> Pedro
>>
>>
>> ----- Original Message ----- 
>> From: "Stuart McLachlan" <stuart at lexacorp.com.pg>
>> To: "Access Developers discussion and problem solving"
>> <accessd at databaseadvisors.com>
>> Sent: Monday, July 13, 2009 6:34 PM
>> Subject: Re: [AccessD] calculation
>>
>>
>> > Select Patient,Dcount("*","myTable","Patient = '" & Patient & "' AND B = 3) /
>> > Dcount("*","myTable",Patient = '" & Patient & "'") * 100 Group  by Patient
>> >
>> >
>> > On 13 Jul 2009 at 15:55, pedro at plex.nl wrote:
>> >
>> >> Hello Group,
>> >>
>> >> i need to calculate the percentage(%) of the value B3 in access for the
>> >> total of numbers of B.
>> >>
>> >> The table that is have:
>> >>
>> >> ID    patient    B
>> >> 1     AA         1
>> >> 2     AA         1
>> >> 3     AA         2
>> >> 4     AA         3
>> >> 5     BB         1
>> >>
>> >>
>> >> Query:
>> >>
>> >> patient    B(%)
>> >> AA         25
>> >>
>> >> How can i do this?
>> >>
>> >> Thanks
>> >>
>> >> Pedro






More information about the AccessD mailing list