> I can't figure out how to output a query to the hundreth place, I
> can format
> the number to the Hundereth, but CF or SQL Server round it to the nearest
> number. I am currently running CF 4.5.1 with SQL Server.
>
> Here's my query and output:
>
> <cfquery name="GetTeamStats" datasource="#DS#" username="#DSUsername#"
> password="#DSPassword#">
> SELECT AVG(BB_BoxGame.HTotal) AS HomeAvg,
> SUM(BB_BoxGame.HTotal) AS HomeTotal,
> AVG(BB_BoxGame.VTotal) AS VisitAvg,
> SUM(BB_BoxGame.VTotal) AS VisitTotal
> FROM BB_BoxGame
> WHERE BB_BoxGame.HomeID = 187 OR BB_BoxGame.VisitorID = 187
> </cfquery>
>
> <cfoutput query="GetTeamStats">
> Home Average / #Numberformat(HomeAvg, "99.99")#<br>
> Home Total / #HomeTotal#<br>
> On the Road Average / #Numberformat(VisitAvg, "99.99")#<br>
> On the Road Total / #VisitTotal#<br>
> </cfoutput>
The return value for AVG depends on the field type;
Thus an Int will always return an Int, a Float will always return a Float,
etc.
If you want to get decimals from the AVG, then Convert it first;
SELECT AVG(Convert(Float,BB_BoxGame.HTotal)) AS HomeAvg,
SUM(BB_BoxGame.HTotal) AS HomeTotal,
AVG(Convert(Float,BB_BoxGame.VTotal)) AS VisitAvg,
SUM(BB_BoxGame.VTotal) AS VisitTotal
FROM BB_BoxGame
WHERE BB_BoxGame.HomeID = 187 OR BB_BoxGame.VisitorID = 187
Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133
"Websites for the real world"
**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************
> -----Original Message-----
> From: Jason Larson [mailto:[EMAIL PROTECTED]]
> Sent: 01 February 2001 17:12
> To: CF-Talk
> Subject: AVG a Query to a Decimal
>
>
>
>
> Thanks
> Jason Larson
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists