按声明分组

时间:2019-05-03 16:05:58

标签: mariadb

使用以下代码时,我收到语法错误:

SELECT students.ID, students.LNAME, students.FNAME, students.PROGRAM,
enrollments.CAMPUS, enrollments.PROGRAM, enrollments.STATUS,
enrollments.STARTDATE, enrollments.DROPDATE, enrollments.GRADDATE, 
programcost.tuition, programcost.books, programcost.other,
accountledger.id, accountledger.transactionamount, 
sum(accountledger.TRANSACTIONAMOUNT) AS 'TotalCost' GROUP BY accountledger.id


FROM students LEFT JOIN enrollments ON students.ID = enrollments.ID
LEFT JOIN programcost ON students.PROGRAM = programcost.programcode
INNER JOIN accountledger 
ON enrollments.ID = accountledger.ID 
AND enrollments.ENROLLMENTNUMBER = accountledger.ENROLLMENTNUMBER   

目标:

每个学生在accountledger.amount字段中可能有多个条目。最终,我希望能够按students.id或accountledger.id进行分组

非常感谢您的帮助。

0 个答案:

没有答案