mysql - SUM of Column where Multiple Rows Have Same Value -


i trying sum of single column rows share similar data. example, given following data:

|ppid | cid   | count | namespace| |-----|-------|-------|----------| |586  | 18281 | 1     | lab      | |587  | 18269 | 1     | lab      | |588  | 18281 | 1     | lab      | |589  | 17823 | 1     | ipb      | |590  | 18281 | 1     | lab      | |591  | 18256 | 1     | lab      | |592  | 18256 | 1     | lab      | |593  | 18269 | 1     | ipb      | |-----|-------|-------|----------| 

i'm hoping get:

|ppid | cid   | count | namespace| |-----|-------|-------|----------| |586  | 18281 | 3     | lab      | |587  | 18269 | 1     | lab      | |589  | 17823 | 1     | ipb      | |591  | 18256 | 2     | lab      | |593  | 18269 | 1     | ipb      | |-----|-------|-------|----------| 

i've pieced couple of different things , come `

select * popularpages  cid in (select cid popularpages                group cid                having count(cid) > 1)  order cid, namespace 

which list out each of rows without counting sum of count column. appreciated.

is want ?

select   min(ppid) ppid,   cid,   sum(`count`) count,   namespace popularpages group cid having count > 1; 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -