Mysql query using where and group by clause

后端 未结 2 1559
清酒与你
清酒与你 2020-12-20 11:56

I have the following table.

mysql> select * from consumer9;
+------------+--------------+-------------------+
| Service_ID | Service_Type | consumer_feedb         


        
2条回答
  •  甜味超标
    2020-12-20 12:32

    The following query should work.

    select Service_ID, Service_Type, sum(consumer_feedback) 
    from consumer9 
    where Service_Type=Printer
    group by Service_ID, Service_Type;
    

    Remember, the where clause goes before the group by clause and all non-aggregated terms in the select part will have to be present in the group by clause.

提交回复
热议问题