|
-
Feb 9th, 2003, 04:35 PM
#1
Thread Starter
Frenzied Member
Counting....
If I want to Count the number of times something occurs in a Table how do I do that...
I could do with the Recordcount property to get a total figure. For example
If a following table exists:
A
A
A
A
B
B
C
D
D
How do I know how many times does A exists and so on....
-
Feb 9th, 2003, 04:50 PM
#2
Addicted Member
Well, I don't use Microsoft's implementation of SQL, but on MySQL, the following would do what you are looking for:
Select count(*) from Table where row1="A"
-
Feb 9th, 2003, 04:50 PM
#3
Code:
SELECT Count(SomeField) As RowCount WHERE SomeField="A"
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Feb 9th, 2003, 05:19 PM
#4
Thread Starter
Frenzied Member
Thanks crptcblade
Can it be counted without doing an SQL statement? Is it possible to do it programatically???
-
Feb 9th, 2003, 05:40 PM
#5
Frenzied Member
What do you mean by 'to do it programatically'? The sql statement is the better way to do it. But you can open your table and then loop through it to count A's , B's and other. In that case this will take much longer to count it.
VB Code:
Dim countA, countB, countC
countA=0
countB=0
countC=0
Do Until rs.EOF
Select Case rs("YourFieldName")
Case "A"
countA=countA+1
Case "B"
countB=countB+1
Case "C"
countC=countC+1
End Select
rs.MoveNext
Loop
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|