SQL query with avg and group by

前端 未结 2 445
自闭症患者
自闭症患者 2020-12-01 12:35

I have some problems with writing a SQL query for MySQL. I have a table with the following structure:

mysql> select id, pass, val from data_r1 limit 10;
+         


        
2条回答
  •  我在风中等你
    2020-12-01 12:46

    As I understand, you want the average value for each id at each pass. The solution is

    SELECT id, pass, avg(value) FROM data_r1
    GROUP BY id, pass;
    

提交回复
热议问题