2016-12-15 76 views
1

有沒有一種方法可以從某個特定配置文件字段中獲取數據。Moodle SQL可配置報告

SELECT u.username AS 'User Name', 
CONCAT(u.firstname,' ',u.lastname) AS 'Full Name', 
u.department AS 'Organisation', 
c.fullname AS 'Course Name', 
DATE_FORMAT(FROM_UNIXTIME(p.timeenrolled),'%m/%d/%Y') AS 'Enrollment Date', 
DATE_FORMAT(FROM_UNIXTIME(p.timecompleted),'%m/%d/%Y') AS 'Completion Date', 
DATE_FORMAT(DATE_ADD(FROM_UNIXTIME(p.timecompleted),INTERVAL 1 YEAR), '%Y-%m-%d') AS 'Expiration Date' 

FROM prefix_course_completions AS p 
JOIN prefix_course AS c ON p.course = c.id 
JOIN prefix_user AS u ON p.userid = u.id 

WHERE 1 = 1 
%%FILTER_SUBCATEGORIES:cc.path%% 
%%FILTER_COURSES:Course%% 
%%FILTER_USERS:Department%% 
%%FILTER_SEARCHTEXT:u.firstname:~%% 
ORDER BY u.firstname 

我可以這樣做

%%FILTER_USERS:Department="SCIENCE DEPARTMENT"%%

這樣的報告只會顯示來自科學系的用戶。在此先感謝

+0

有人嗎?請?即使我搜索,我仍然沒有找到答案。 – Nightshade

回答

0

我想你可以簡單地在WHERE子句類似應用它:

WHERE u.department = 'SCIENCE DEPARTMENT'