订单是 11 月和 10 月。我怎样才能将 ORDER BY 添加到此,以便按月、1 月、2 月、3 月...等顺序排列。
提前致谢。
CREATE TABLE `hw_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` date NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=55 ;
--
-- Dumping data for table `hw_homework`
--
INSERT INTO `hw_homework` (`id`, `studentid`, `subjectid`, `assignment_name`, `teacherid`, `date`) VALUES
(52, 56, 13, '1A', 20, '2012-10-28'),
(53, 56, 6, '12', 18, '2012-10-28'),
(54, 56, 4, 'page42', 59, '2012-11-02');
SELECT studentID,
DATE_FORMAT(`date`,'%M') `month`,
COUNT(studentid) totalMissed
FROM hw_homework
WHERE studentid = 56
GROUP BY studentid, DATE_FORMAT(`date`, '%M')