----- Original Message -----
Sent: Sunday, March 02, 2003 10:42
AM
Subject: Re: Witango-Talk:
searching for elegant count sql statement
this should do what your looking
for:
sel count(distinct studentname) from
tablename group by studentname
if i understand you correctly
----- Original Message -----
Sent: Sunday, March 02, 2003
10:23 AM
Subject: Re: Witango-Talk:
searching for elegant count sql statement
oops, disregard that last one, I misread your question.
Brent
Hi, I have a database with a table
which contains multiple student id's,
+----------+------------------+------+-----+---------+----------------+
|
Field | Type | Null | Key | Default | Extra
|
+----------+------------------+------+-----+---------+----------------+
|
projID | int(11) | | | 0 | |
| stuID | int(11) | | | 0 |
|
| rank | int(11) | | | 0 | |
| uniqueID | int(10)
unsigned | | MUL | NULL | auto_increment
|
+----------+------------------+------+-----+---------+----------------+
4
rows in set (0.00 sec)
most occurring more than once
since a student may make multiple requests which are stored in
the table. I want to count the number of times each student name
occurs, and then store the frequency in an array. I thought that
the sql count function would help, but it seems not directly. I
had to first do a search to find each unique id (using
distinct), then with a for loop iterate through the resultset,
and do a search for each id, and then add each numrows value to
an array.
I also tried bracketing the second search
between two results html with a beginning and ending rows loop,
but that doesn't seem to work either!
So, short version
is I have the thing working (see attached taf) but seems like a
lot of work that should be able to be accomplished in a single
select statement.
Thanks for any insights.
John
Newsom
/fontfamily>
________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
with unsubscribe witango-talk in the message body
________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
with unsubscribe witango-talk in the message body