表A,字段:id,name,total,三字段
1 xiao 5
2 da 2
2 xiao 3
2 xiao 1
3 wang 3
……
求:select id,sum(total) from 表A
select id,sum(total) from 表A where name='xiao'
我想把这两条sql语句合并成一条,如何实现?(注:是mysql中)
1 xiao 5
2 da 2
2 xiao 3
2 xiao 1
3 wang 3
……
求:select id,sum(total) from 表A
select id,sum(total) from 表A where name='xiao'
我想把这两条sql语句合并成一条,如何实现?(注:是mysql中)
union all
select id,sum(total) from 表A where name= 'xiao '