MySQL: Get total in last row of MySql result

前端 未结 6 528
夕颜
夕颜 2020-12-10 04:29

For example I have a table like this:

product | quantity | something
-------------------------------
 abc    |   5      |  2
 xzy    |   5      |  2
 asd             


        
6条回答
  •  清歌不尽
    2020-12-10 04:56

    it's not the best way to solve this but should do the trick

    select product, quantity, something from tableName
    union 
    select 'sum', sum(quantity), sum(something) from tableName
    

提交回复
热议问题