er det noget ala dette du søger ??
test på en mysql database
test database
CREATE TABLE IF NOT EXISTS `tbl_point` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user_id` int(11) NOT NULL,
`point` int(11) NOT NULL,
`dato` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_danish_ci AUTO_INCREMENT=5 ;
--
-- Data dump for tabellen `tbl_point`
--
INSERT INTO `tbl_point` (`id`, `user_id`, `point`, `dato`) VALUES
(1, 1, 10, '2015-02-15 00:00:00'),
(2, 1, 5, '2015-02-02 00:00:00'),
(3, 1, 5, '2015-01-22 00:00:00'),
(4, 2, 36, '2015-02-15 00:00:00');
SELECT sum(`point`) as sum_point FROM `tbl_point` WHERE `user_id` = 1 and MONTH(dato) = 2 and YEAR(dato) = 2015
eller mere dynamisk
SELECT sum(`point`) as sum_point FROM `tbl_point` WHERE `user_id` = 1 and MONTH(NOW()) = MONTH(dato) and YEAR(NOW()) = YEAR(dato)
output
15
SELECT sum(`point`) as sum_point, count(id) as antal FROM `tbl_point` WHERE `user_id` = 1 and MONTH(NOW()) = MONTH(dato) and YEAR(NOW()) = YEAR(dato)
15
2
ellers kan prøve at kigge på datepart
http://www.w3schools.com/sql/func_datepart.asp