CGridView displaying result of SUM query


I’m playing around with the CGridView widget and I’m trying to find out if it would be appropriate to use it in the following context:

Lets say I have two database tables, Car and Accident. Each car may be associated to zero or more accidents. I would like to have a column in the grid view containing the number of accidents for each car, assuming that a row in the grid view represents a car.

Is this feasible using a GridView widget, or should I try some other approach?


Yes it is. You can add array, something like this :





in your CGridView columns on your view file that show Car list.

@itmagetan: Thanks a lot, that indeed solved the problem :)