Hi All -
I've looked at the documentation and perused a number of other posts, but I cannot seem to find a solution for my scenario. I want to provide a "special" user in a course the ability to run ad-hoc reports queries. Therefore I need the ad-hoc queries to dynamically use information from the "special" user's profile (i.e. their institution). For example, the ad-hoc report I want to create would let the special user see all students from their institution in a course (and their respective grade).
Problem is, unless I hard code the institution it doesn't seem to dynamically assign based on the special user logged in.
SELECT u.firstname AS 'Name' , u.lastname AS 'Surname', c.fullname AS 'Course'
FROM prefix_course AS c
JOIN prefix_user AS u
WHERE u.institution='%%USERID%%'
ORDER BY `Name` ASC
The above query, when run by the "special" user will not show any report results. If I hard-code an institution value, then I get users from that institution; but I want it to be dynamic since I have special users from multiple institutions. I'm sure what I'm failing to do is fairly simple, but it's been a while since I've written in MySQL (and I do realize the above query would not give me grades, I'm just trying to get it to pull the correct users first).