How-to Goup By with Template

How-to Goup By with Template

by Alan Hare -
Number of replies: 0

Juan Leyva or anyone,

How would I Group By in the Template?

Example query:  

SELECT u.username AS 'Student',
c.fullname AS 'Course',
gi.itemname AS 'Module',
CONVERT(VARCHAR, DATEADD(s, gg.timemodified, '19700101'), 22) AS 'Date'

FROM prefix_course AS c
JOIN prefix_context AS ctx ON c.id = ctx.instanceid
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id
JOIN prefix_user AS u ON u.id = ra.userid
JOIN prefix_grade_grades AS gg ON gg.userid = u.id
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid
JOIN prefix_course_categories AS cc ON cc.id = c.category

WHERE  gi.courseid = c.id
AND gi.itemname != 'Attendance'
AND CAST((gg.finalgrade) AS DECIMAL) > '99'
AND u.deleted = 0
%%FILTER_STARTTIME:gg.timemodified:>%%
%%FILTER_ENDTIME:gg.timemodified:<%%
%%FILTER_COURSES:c.id%%

GROUP BY c.fullname, gi.itemname, u.username, CONVERT(VARCHAR, DATEADD(s, gg.timemodified, '19700101'), 22)

 

I am trying to only list the 'Student' and 'Course' once in a table and have the multiple 'Modules' with 'Date's completed listed bellow.

John Doe

Course Name 2

Module Name 1 01/01/2013
Module Name 2 01/02/2013

 

 

 

Jane Smith

Course Name 2

Module Name 1 01/01/2013
Module Name 2 01/01/2013
Module Name 5 01/06/2013
Module Name 7 01/01/2013

 

 

Average of ratings: -