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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AVG

Status
Not open for further replies.

skezza

Programmer
Nov 17, 2008
2
GB
Hi Guys,
Thanks for the help with the last query, hopefully I am on my way to completing this now.
I need to make an QUERY to deduce the average ticket sales sold. As each ticket has a date assigned to it, i obviously first need to count the tickets and group them by the park name. I've done that, but in the same query, i need to then have it average the list it returns to show me the overall average. How would i go about doing that? Basically, it returns a list of each park and how many tickets they have sold, i need to provide an average for that list.

SELECT `tblThemePark`.`ParkName` , COUNT( `tblOrders`.`TicketID` )
FROM `tblThemePark`
JOIN `tblOrders` ON `tblThemePark`.`ParkID` = `tblOrders`.`ParkID`
GROUP BY tblThemePark.ParkName

Cheers
 
SELECT AVG(myCount)
FROM (SELECT COUNT(TicketID) myCount FROM tblOrders GROUP BY ParkID
) C

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
You mean the average as all tickets sold divided by the number of parks?

[tt]
SELECT COUNT(*) / COUNT(DISTINCT ParkID)
FROM tblOrders;
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top