Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Database > SQL Language
|
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 30th, 2004, 08:15 AM
Registered User
 
Join Date: Mar 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Averaging Grouped Data

I have a related problem. I am running this select:

SELECT max(datename(mm, dateenquiry)) As [Month],
    datepart(yyyy, Dateenquiry) AS [Year],
    count(name) as [Frequency],
    sum(ValueofClaim) as [Total Value],
    sum(Expences) as [Monthly Expense]

From JC_Entities

GROUP BY DATEPART(yyyy, Dateenquiry),
    DATEPART(m, dateenquiry)
ORDER BY DATEPART(yyyy, Dateenquiry),
    DATEPART(m, dateenquiry)

which works to give me the number of items and the totals of columns, but I now want to arrive at an AVG for each row and to perform a calculation say [Monthly Expense] / [Frequency].

I have failed to get this any further and I wanted to run it from an .aspx file as a stored procedure.

Any help would be appreciated.


Andy Hodges

Andy Hodges
 
Old April 6th, 2004, 09:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

In case you are using MSSQL server you can check BOL for COMPUTE clause and its examples.

-Vijay G





Similar Threads
Thread Thread Starter Forum Replies Last Post
Apply Paging on Grouped Data jhansib4u XSLT 4 November 26th, 2007 01:30 PM
Grouped and sorted table row numbers ADenny XSLT 1 April 24th, 2006 10:06 AM
Calculating Grouped Report Values SteveH Access 1 October 15th, 2005 03:00 PM
numbers on grouped records mkapler Access 2 March 6th, 2005 05:49 PM
Multiple controls - grouped william.murray Access 2 August 4th, 2004 04:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.