Steve is right. You can't have zero as the denominator. I totally forgot about that. Sorry. Ann, it is very likely that some of your fields contain zero values. nathan
----- Original Message ----- From: "Steven Durette" <[EMAIL PROTECTED]> To: "CF-Talk" <[EMAIL PROTECTED]> Sent: Sunday, February 17, 2002 10:34 PM Subject: Re: Calculations in Query? > Ann, > > This might not have worked if you have any zeros in the D_Goal column. > > This would work for SQL Server, and should work for Access, but I'm not > sure. > > SELECT D_ID, D_Name, > (CASE D_Goal WHERE 0 THEN 0 > ELSE D_Loss/D_Goal*100) as MyValue > FROM diet > > Steve > > ----- Original Message ----- > From: "Ann Harrell" <[EMAIL PROTECTED]> > To: "CF-Talk" <[EMAIL PROTECTED]> > Sent: Sunday, February 17, 2002 11:25 PM > Subject: RE: Calculations in Query? > > > > Thanks, Nathan. I didn't work for me, but that probably has more to do > wi > > th > > the lateness of the hour than anything. I'll start fresh in the morning. > > > > Ann Harrell > > > > -----Original Message----- > > From: Nathan Chen [mailto:[EMAIL PROTECTED]] > > Sent: Sunday, February 17, 2002 11:01 PM > > To: CF-Talk > > Subject: Re: Calculations in Query? > > > > > > Of course it is possible. Try > > SELECT D_ID, D_Name, D_Loss/D_Goal*100 as MyValue > > FROM diet > > > > Then put a % after the output value. e.g. <cfoutput>#MyValue#</cfoutput > >% > > > > ----- Original Message ----- > > From: "Ann Harrell" <[EMAIL PROTECTED]> > > To: "CF-Talk" <[EMAIL PROTECTED]> > > Sent: Sunday, February 17, 2002 8:41 PM > > Subject: Calculations in Query? > > > > > > > I'm trying to figure a percentage in a query. I don't know if it's > > possible. > > > I would like to D_Loss / D_Goal and then output the percentage. I'm u > si > > ng > > an > > > Access database if that helps. > > > > > > <CFQUERY NAME="QDiet" DATASOURCE="met"> > > > SELECT D_ID, D_Name, D_Loss, D_Goal > > > FROM diet > > > ORDER BY diet.D_Name > > > </CFQUERY> > > > > > > Thanks! > > > > > > Ann Harrell > > > > > > > > ______________________________________________________________________ Why Share? Dedicated Win 2000 Server · PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER Instant Activation · $99/Month · Free Setup http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists