[英]Count total values for given month
I have this mySQL statement: 我有这个mySQL语句:
SELECT COUNT(clicks) FROM ads.statz WHERE user_id = '$_SESSION[user_id]'
Works fine it counts all the number of clicks with the given user id. 工作正常,它会计算具有给定用户ID的所有点击次数。 What I am after is being able to group together the numbers for each month as a total.
我需要的是能够将每个月的数字总计在一起。 I need this for both Clicks and impressions.
点击和展示都需要这个。
Here is the layout of the DB. 这是数据库的布局。
CREATE TABLE `statz` (
`ad_id` int(50) NOT NULL,
`date` datetime NOT NULL,
`clicks` int(50) NOT NULL,
`impressions` int(50) NOT NULL,
`user_id` int(50) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Thanks! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.