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

Popular posts from this blog

iis - ASP.Net Core CreatedAtAction in HttpPost action returns 201 but entire request ends with 500 -

ssh - Vagrant Windows - ssh_exchange_identification: read: Connection reset by peer -

gcc - Neither ld wrap nor LD_PRELOAD working to intercept system call -