Forums

This topic is locked

SQL Count Statement

Posted 07 Mar 2006 05:24:28
1
has voted
07 Mar 2006 05:24:28 Quan Lowery posted:
<font face='Verdana'>I am a ColdFusion developer and I have a form that contains about 100 checkbox items. A user selects multiple items, submits it, and each item is inserted into it's "own row" in an MS Access database. The database consists of only 2 columns: ID and Checklist. I need a SQL statement that will count each "instance" of the checklist item. For instance, the following entries are in the database:

ID Checklist
1 Yellow
2 Blue
3 Green
4 Yellow
5 Yellow
6 Green

How do count how many times each item in the "Checklist" column is listed in the database?</font id='Verdana'>

Replies

Replied 07 Mar 2006 16:32:10
07 Mar 2006 16:32:10 Roddy Dairion replied:
select count(tablename.fieldname) from tablename inner join tablename2 on tablename.fieldname = tablename2.fieldname

Replied 07 Mar 2006 16:36:41
07 Mar 2006 16:36:41 Quan Lowery replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
select count(tablename.fieldname) from tablename inner join tablename2 on tablename.fieldname = tablename2.fieldname

<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Thanks, but that's not going to work. There's only one table so there's nothing to join.
Replied 07 Mar 2006 16:44:51
07 Mar 2006 16:44:51 Roddy Dairion replied:
select Checklist, count(ID) as NumOcurrence from tablename group by Checklist

let me know if it works.
Replied 07 Mar 2006 20:28:39
07 Mar 2006 20:28:39 Quan Lowery replied:
I've already found a solution to the problem
Replied 07 Mar 2006 20:35:49
07 Mar 2006 20:35:49 Roddy Dairion replied:
Wats the solution??

Reply to this topic