Hi,
[this has got nothing to do with transactions - post stuff like this to the general forum next time]
Well, there is something strange here. You GROUP BY only col2, but you SELECT *; that is, you SELECT id, col1 and col2. As a general principle, you should GROUP BY all the expressions that define a group. For each group that you select in this way, you can SELECT an aggregate: COUNT, SUM, AVG etc (see
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html). It is an error to have those expressions in your GROUP BY list.
So first, you have to have a clear idea what defines a group. Is it col1? Your query seems to imply that, because you have a WHERE col1 = 'someval' clause. However, your resultset contains two distinct values for col1, a1 and a2, so what's the deal here? Is that your total data set?
Please post exactly what you want your query result to be for a particular query for a particular dataset. Thank you.
Roland