php - Mysql multiple SUM in one query - novice -


i counting clicks per category of ads. curently passing category function, have 10 cats, calling function 10 times number of clicks each category. trying figure out possible in 1 query. started mysql code:

select sum(clicks) 'clicks' wp_cb_ads_manager category = '.$cat.' 

and gives me

array ( [0] => stdclass object ( [clicks] => 11 ) )  

is possible on 1 query, retrieve sum per each category in array. here screen of how 2 tables looks like:

http://awesomescreenshot.com/00018kly6d http://awesomescreenshot.com/06418kltcc

in first keep list of categories, , in second keep ads 1 field used check in category ad.

if i'm reading screenshots correctly, display sum grouped category;

select category, sum(clicks) clicks  wp_cb_ads_manager  group category 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -