Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to add totals 1

Status
Not open for further replies.

NFLDUser

IS-IT--Management
Apr 17, 2006
47
CA
I have a query that reads a table to get my payment methods and return the number of purchases by payment type.

But I have also have a field called 'paid' that I would like to get the average totals for each payment type. I'm not sure how to go about this...

SELECT TOP 10 method, Count(*) AS newvar From Billing GROUP BY method ORDER BY 2 DESC

That's what I have...but this is the table I am looking to get.

method newvar avgvalue
-----------------------------------
visa 54 $45
amex 10 $65
cash 10 $95

Ideas?
 
Have you tried this ?
SELECT TOP 10 method, Count(*) AS newvar, CCur(Avg(paid)) AS avgvalue
FROM Billing
GROUP BY method
ORDER BY 2 DESC

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top