Select Sum and multiple columns in 1 select statement

前端 未结 4 1554
醉酒成梦
醉酒成梦 2021-01-07 14:14

Is there a way to select the sum of a column and other columns at the same time in SQL?

Example:

SELECT sum(a) as car,b,c FROM toys
4条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-07 14:55

    try add GROUP BY

    SELECT sum(a) as car,b,c FROM toys 
    GROUP BY b, c
    

提交回复
热议问题