Merry Meet Robert,
You can't put you if inside your query.  It wont work.  As you've seen.  Use
this instead.

<cfquery name="Get" datasource="wweb">
   SELECT id, cbi, count(cbi) as cbicount
   FROM wweb
   Where cbi like 'CBI'
</cfquery>

<CFOUTPUT>
#get.cbiCount#
</CFOUTPUT>

That should work for you.

Blessed Be,
--Katrina Chapman
http://www.katrinachapman.com
http://www.cfchick.com


-----Original Message-----
From: Robert Orlini [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 3:48 PM
To: CF-Talk
Subject: data in columns


Hello,

I'm still a newbie with this one though I've tried. How can I count data in
certain columns of a table for each record. Some records have no data in
this field of the column so of course I don't want that counted. I kept it
VERY VERY simple below. I've tried different configurations, but #cbicount#
always returns a blank.

Any help is always appreciated. Thank you.

Robert O.
----------------------------------

Below I'm trying to count how many times CBI appears in the cbi column and
display the total tally in the #cbicount# variable:

<cfquery name="Get" datasource="wweb">
   SELECT id, cbi
   FROM wweb
   Where cbi like 'CBI'

<cfif cbi EQ "CBI">
   <cfset cbicount + 1>
</cfif>

</cfquery>

<CFOUTPUT>
#cbiCount#
</CFOUTPUT>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to