删除WITH ROLLUP导致的第二行

时间:2013-08-25 09:11:54

标签: mysql

我需要删除第2行结果,其中包含第1行总记录的副本。我的结果集如下

1 | 1025

1 | NULL ---我需要删除这一行

我的查询如下:

SELECT SUM( mdl_quiz.fcpd ) AS cpdtotal, mdl_user.id AS userid
FROM mdl_grade_grades
INNER JOIN mdl_user ON mdl_grade_grades.userid = mdl_user.id
INNER JOIN mdl_grade_items ON mdl_grade_grades.itemid = mdl_grade_items.id
INNER JOIN mdl_quiz ON mdl_grade_items.itemname = mdl_quiz.name
INNER JOIN mdl_course ON mdl_grade_items.courseid = mdl_course.id
INNER JOIN mdl_user_info_data ON mdl_user.id = mdl_user_info_data.userid
WHERE mdl_user_info_data.fieldid =1
AND mdl_grade_items.itemname IS NOT NULL 
AND mdl_user.annualCPDReportActive =  'Y'
AND (
     mdl_course.category =27
    )
AND mdl_user.id =1025
AND YEAR( FROM_UNIXTIME( mdl_grade_grades.timemodified ) ) =2013
GROUP BY mdl_user.id
WITH ROLLUP

1 个答案:

答案 0 :(得分:0)

您应该删除WITH ROLLUP 更多信息here