Aggregating MySQL Data help please!
Hi,
I am a relatively new MySQL user and I wonder if anybody out there knows a way to run an aggregate query on a table like mine. My table contains weekly data on teams and points won. On week 1 Team A plays at Home, on Week 2 Team A plays away, on Week 3 Team A is at home again etc, etc
The table fields are as follows;
Wk_No, Hosts, H_pts, Visitors, V_pts
Typical data in the fields would be as follows;
1, Team A, 12, Team D, 2
1, Team C, 8, Team B, 6
2, Team B, 10, Team A, 4
2, Team D, 7, Team C, 7
3, Team A, 8, Team B, 6
3, Team D,14, Team C, 0
I am trying to group the data by team and totalise the pts won away and the points won at home as Tpts scored by team in the form of a league table.
I would like my result to look like this;
Team TPts
Team A 24
Team B 22
Team C 15
Team D 23
I have tried using temporary tables which works well on the MySql server but I can't get it to display on my web page via a php page. I don't have permissions to create VIEWS on my server either!
Are there any MySQL whizzes out there that can advise me? This is driving me nuts!
Any advice would be much appreciated
|