Or if you wanted to let your SQL do everything:

select d_id,d_name, Convert(varchar(3), ((d_Loss/d_Goal) * 100)) + '%' as
Percent
from diet
order by d_name

You can use the Convert (or Cast, your preference) to change the math result
into a VarChar field and then append the % sign on all within the query.

Hatton


> -----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 using
> 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/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to