SELECT count / group by question

wxdqz

New Member
am doing a query to pull out data from one of my tables, using this select

SELECT match_info.season_id, count(match_info.season_id) as count, sum(match_info.for) as count1, sum(match_info.against) as count2, global_season.season_name from match_info, global_season WHERE match_info.season_id = global_season.id AND match_info.match_date <= curdate() GROUP BY match_info.season_id ORDER BY match_info.season_id

This works fine, pulls out the season id and then then the total amount of matches for the season, the goals scored (for) and the goals against (against) and also the season name (its a football styled website )

The data looks something like


2 1 2 1 00/01
1 12 43 25 01/02

In the table, I have 13 records ... each record has a field (called RES) that stores either a W a D or a L

It only can have one of those values and basically I'd like my query to show three extra columns

2 4 2 1 00/01
plus 3 2 1

The new values are 3 = Number of rows with a W in, 2 = number of rows with a D in and finally 1 = number of rows with a L in

Any ideas?
 
Back
Top