sql - mysql sum only specific groups of a table -
is there way sum specific groups of table? example if have
keys / vals / 1 / 2 b / 3 b / 3 c / 1 c / 1
and want grouping , c not others such b above:
keys / vals / 3 b / 3 b / 3 c / 2
this seems straightforward stored proc not sure if possible query?
union all
non-b part b part:
select keys, sum(vals) tablename keys <> 'b' group keys union select keys, vals tablename keys = 'b'
Comments
Post a Comment