I have the following db table which shows missed homework.
CREATE TABLE `missed_homework` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`studentid` int(10) NOT NULL,
`subjectid` int(10) NOT NULL,
`assignment_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`teacherid` int(10) NOT NULL,
`date` datetime NOT NULL,
PRIMARY KEY (`id`)
) ... ;
INSERT INTO `missed_homework` (`id`, `studentid`, `subjectid`, `assignment_name`, `teacherid`, `date`) VALUES
(1, 29, 5, '5E', 20, '2012-10-18 13:58:40'),
(2, 15, 5, '32B', 20, '2012-10-18 13:59:54'),
(3, 29, 4, 'Q2A', 20, '2012-10-18 17:53:46'),
(4, 29, 11, '6E', 20, '2012-10-02 20:06:39'),
(5, 29, 11, 'C15', 20, '2012-10-16 20:06:30'),
(6, 15, 11, '7A', 20, '2012-09-19 20:08:05'),
(7, 29, 5, '3B', 20, '2012-09-14 20:08:12'),
(8, 29, 13, '6E', 32, '2012-10-18 20:23:46'),
(9, 29, 11, '7E', 18, '2012-10-20 14:35:14')......
I am not sure how to do the followings.
- I want to find total number of missed homework by say, studentid=29 grouped by month.
- same as above except grouped by week.
I tried the followings but it does not output what I want.
$this->db->where('studentid',$id);
$this->db->from('missed_homework');
$this->db->group_by('date');
$query=$this->db->get();