views:

43

answers:

2

Hi,

I want write these SQL Query:

CREATE VIEW `uniaverage` AS 
  SELECT `averagegrade`.`mjr`,`averagegrade`.`lev`, 
     AVG(`averagegrade`.`average`) AS `uniAVG` 
  FROM `averagegrade` GROUP BY `averagegrade`.`lev`, `averagegrade`.`mjr`;

But MySQL Query Browser give this error:

Operand Should Contain 1 column(s)

I somewhere read can use group by on more than 1 column!!! How can I solve this error? or how can I change the Query to get the same result?

+3  A: 

You can do this:

GROUP BY CONCAT(field1, field2, field3, etc)

Hope this helps..

Ian P
A: 

There's a problem with your syntax. You are passing two operands to the AVG aggregate function. It takes just one operand.

(More correctly, you're passing in one operand, but it's a column list, rather than the single column the AVG function is expecting.)

mdma