PDA

View Full Version : Count problems


Speedy
05-13-2006, 01:06 AM
Hi,

I got a problem with a Count function.

in a access db I have fields named AMT1 up to AMT18
each of theese fields can contain the numbers 1 to 7

What I want to do is to count how many 1 all of the AMT1 to AMT18
contains all together.

the code below gives me the value 8 and that is correct I have eight 1 in
AMT1

<% Set Antal1=Conn.Execute("Select Count(*) As ettor From tbl_res Where AMT1=1 AND PlayerId ='"& strpID &"' ") %>
<%= Antal1("ettor") %>


But how do I count how many 1 I have alltogether??

I tested to do it like this:

<% Set Antal1Tot=Conn.Execute("Select Count(*) As ettor From tbl_res Where AMT1=1 AND AMT2=1 AND PlayerId ='"& strpID &"' ") %>
<%= Antal1Tot("ettor") %>


but that code gives me the value 2 but should return the value 11
AMT1=1 = 8
AMT2=1 = 3
8+3=11

Any ideas??

/Speedy

mehere
05-13-2006, 01:36 AM
try making it OR instead of AND
<% Set Antal1Tot=Conn.Execute("Select Count(*) As ettor From tbl_res Where AMT1=1 OR AMT2=1 AND PlayerId ='"& strpID &"' ") %>

Speedy
05-13-2006, 07:30 AM
Mehere,

that makes me even more confused, that returns 130 (should be 11)

any other ideas?